update the new school year model
This commit is contained in:
@@ -7,6 +7,7 @@ use App\Http\Requests\SchoolYears\CloseSchoolYearRequest;
|
||||
use App\Http\Requests\SchoolYears\PreviewCloseSchoolYearRequest;
|
||||
use App\Http\Requests\SchoolYears\SaveSchoolYearRequest;
|
||||
use App\Services\SchoolYears\SchoolYearClosureService;
|
||||
use App\Services\SchoolYears\SchoolYearContextService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@@ -14,14 +15,44 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SchoolYearController extends BaseApiController
|
||||
{
|
||||
public function __construct(private SchoolYearClosureService $service)
|
||||
{
|
||||
public function __construct(
|
||||
private SchoolYearClosureService $service,
|
||||
private SchoolYearContextService $context
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index(): JsonResponse
|
||||
public function index(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json(['ok' => true, 'data' => $this->service->list()]);
|
||||
$context = $this->context->options(
|
||||
$request->query('school_year'),
|
||||
$request->query('semester')
|
||||
);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->service->list(),
|
||||
'meta' => $context,
|
||||
'school_years' => $context['school_years'],
|
||||
'current_school_year' => $context['current_school_year'],
|
||||
'current_semester' => $context['current_semester'],
|
||||
]);
|
||||
}
|
||||
|
||||
public function current(Request $request): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $this->context->options(
|
||||
$request->query('school_year'),
|
||||
$request->query('semester')
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public function options(Request $request): JsonResponse
|
||||
{
|
||||
return $this->current($request);
|
||||
}
|
||||
|
||||
public function store(SaveSchoolYearRequest $request): JsonResponse
|
||||
|
||||
Reference in New Issue
Block a user