<?php

namespace App\Domains\Auth\Controllers;

use App\Domains\Auth\Models\User;
use App\Domains\Auth\Resources\AdminAppMeResource;
use App\Domains\Auth\Services\AdminAppContextService;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class AdminAppMeController extends Controller
{
    public function __construct(
        private readonly AdminAppContextService $adminAppContextService,
    ) {}

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

        return AdminAppMeResource::make(
            $this->adminAppContextService->load($user)
        );
    }
}
