inti project
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Contracts\StudentServiceContract;
|
||||
use App\Domain\SchoolCore\Students\Data\CreateStudentData;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
final class StudentCreateController
|
||||
{
|
||||
public function __construct(private readonly StudentServiceContract $students) {}
|
||||
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
$student = $this->students->create($context, new CreateStudentData(method_exists($request, 'validated') ? $request->validated() : $request->all()));
|
||||
|
||||
return response()->json($student->attributes, 201);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user