<?php

namespace App\Domains\Auth\Controllers;

use App\Domains\Auth\Requests\UpdateProfileRequest;
use App\Domains\Auth\Resources\UserResource;
use App\Domains\Auth\Services\ProfileService;
use Illuminate\Http\JsonResponse;

class UpdateProfileController
{
    public function __invoke(UpdateProfileRequest $request, ProfileService $service): JsonResponse
    {
        $user = $service->update($request->user(), $request->validated());

        return response()->json(UserResource::make($user)->resolve());
    }
}
