<?php

namespace App\Domains\Auth\Controllers;

use App\Domains\Auth\Models\User;
use App\Domains\Auth\Resources\ScannerMeResource;
use App\Domains\Auth\Services\ScannerContextService;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class ScannerMeController extends Controller
{
    public function __construct(
        private readonly ScannerContextService $scannerContextService,
    ) {}

    public function __invoke(Request $request): ScannerMeResource
    {
        /** @var User $user */
        $user = $request->user();

        return ScannerMeResource::make($this->scannerContextService->load($user));
    }
}
