28 lines
763 B
PHP
28 lines
763 B
PHP
<?php
|
|
|
|
namespace App\Domains\Auth\Controllers;
|
|
|
|
use App\Domains\Auth\Requests\RegisterUserRequest;
|
|
use App\Domains\Auth\Resources\UserResource;
|
|
use App\Domains\Auth\Services\RegisterUserService;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class RegisterController extends Controller
|
|
{
|
|
public function __construct(
|
|
protected RegisterUserService $registerUserService,
|
|
) {
|
|
}
|
|
|
|
public function __invoke(RegisterUserRequest $request): JsonResponse
|
|
{
|
|
$user = $this->registerUserService->register($request->validated());
|
|
|
|
return UserResource::make($user)
|
|
->additional(['message' => 'Usuario registrado correctamente.'])
|
|
->response()
|
|
->setStatusCode(201);
|
|
}
|
|
}
|