add more controller

This commit is contained in:
root
2026-03-10 00:48:32 -04:00
parent 5eeaec0257
commit 20ee70d153
151 changed files with 9481 additions and 8407 deletions
@@ -0,0 +1,64 @@
<?php
namespace App\Http\Controllers\Api\System;
use App\Http\Controllers\Api\BaseApiController;
use App\Http\Requests\SchoolIds\SchoolIdAssignRequest;
use App\Http\Resources\SchoolIds\SchoolIdResource;
use App\Services\SchoolIds\SchoolIdAssignmentService;
use App\Services\SchoolIds\SchoolIdGenerationService;
use Illuminate\Http\JsonResponse;
class SchoolIdController extends BaseApiController
{
public function __construct(
private SchoolIdAssignmentService $assignmentService,
private SchoolIdGenerationService $generationService
) {
parent::__construct();
}
public function assign(SchoolIdAssignRequest $request): JsonResponse
{
$payload = $request->validated();
$schoolId = $this->assignmentService->assignToUser((int) $payload['user_id']);
if ($schoolId === null) {
return response()->json(['ok' => false, 'message' => 'User not found.'], 404);
}
return response()->json([
'ok' => true,
'result' => new SchoolIdResource([
'type' => 'user',
'school_id' => $schoolId,
]),
]);
}
public function generateStudent(): JsonResponse
{
$schoolId = $this->generationService->generateStudentId();
return response()->json([
'ok' => true,
'result' => new SchoolIdResource([
'type' => 'student',
'school_id' => $schoolId,
]),
]);
}
public function generateUser(): JsonResponse
{
$schoolId = $this->generationService->generateUserId();
return response()->json([
'ok' => true,
'result' => new SchoolIdResource([
'type' => 'user',
'school_id' => $schoolId,
]),
]);
}
}