update project
This commit is contained in:
@@ -0,0 +1,457 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\Integration;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class SchoolWorkflowController extends Controller
|
||||
{
|
||||
public function storeSchool(Request $request): JsonResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'code' => ['nullable', 'string', 'max:64'],
|
||||
'timezone' => ['nullable', 'string', 'max:64'],
|
||||
'locale' => ['nullable', 'string', 'max:16'],
|
||||
'currency' => ['nullable', 'string', 'size:3'],
|
||||
'domain_profile' => ['nullable', 'string', 'max:64'],
|
||||
]);
|
||||
|
||||
$id = (int) DB::table('schools')->insertGetId([
|
||||
'name' => $data['name'],
|
||||
'code' => $data['code'] ?? null,
|
||||
'timezone' => $data['timezone'] ?? 'UTC',
|
||||
'locale' => $data['locale'] ?? 'en',
|
||||
'currency' => strtoupper($data['currency'] ?? 'USD'),
|
||||
'domain_profile' => $data['domain_profile'] ?? 'standard_school',
|
||||
'active' => true,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return $this->ok($this->schoolPayload($id), Response::HTTP_CREATED, 'School created.');
|
||||
}
|
||||
|
||||
public function showSchool(int $school): JsonResponse
|
||||
{
|
||||
return $this->ok($this->schoolPayload($school));
|
||||
}
|
||||
|
||||
public function storeStudent(Request $request, int $school): JsonResponse
|
||||
{
|
||||
$this->assertSchoolExists($school);
|
||||
|
||||
$data = $request->validate([
|
||||
'first_name' => ['required', 'string', 'max:255'],
|
||||
'last_name' => ['required', 'string', 'max:255'],
|
||||
'student_number' => ['nullable', 'string', 'max:128'],
|
||||
'school_id_number' => ['nullable', 'string', 'max:128'],
|
||||
'grade_level' => ['nullable', 'string', 'max:64'],
|
||||
'status' => ['nullable', 'string', 'max:64'],
|
||||
]);
|
||||
|
||||
$studentNumber = $data['student_number'] ?? $data['school_id_number'] ?? null;
|
||||
|
||||
$id = (int) DB::table('students')->insertGetId([
|
||||
'school_id' => $school,
|
||||
'school_id_number' => $studentNumber,
|
||||
'student_identifier' => $studentNumber,
|
||||
'first_name' => $data['first_name'],
|
||||
'last_name' => $data['last_name'],
|
||||
'status' => $data['status'] ?? 'active',
|
||||
'profile_metadata' => json_encode(['grade_level' => $data['grade_level'] ?? null], JSON_THROW_ON_ERROR),
|
||||
'metadata' => json_encode(['grade_level' => $data['grade_level'] ?? null], JSON_THROW_ON_ERROR),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return $this->ok($this->studentPayload($school, $id), Response::HTTP_CREATED, 'Student created.');
|
||||
}
|
||||
|
||||
public function showStudent(int $school, int $student): JsonResponse
|
||||
{
|
||||
return $this->ok($this->studentPayload($school, $student));
|
||||
}
|
||||
|
||||
public function storeAttendanceScan(Request $request, int $school): JsonResponse
|
||||
{
|
||||
$this->assertSchoolExists($school);
|
||||
|
||||
$data = $request->validate([
|
||||
'student_number' => ['required_without:student_id', 'string', 'max:128'],
|
||||
'student_id' => ['required_without:student_number', 'integer'],
|
||||
'scanned_at' => ['nullable', 'date'],
|
||||
'source' => ['nullable', 'string', 'max:64'],
|
||||
'station_id' => ['nullable', 'string', 'max:128'],
|
||||
]);
|
||||
|
||||
$student = $this->findStudentByScanInput($school, $data);
|
||||
$scannedAt = isset($data['scanned_at']) ? Carbon::parse($data['scanned_at']) : now();
|
||||
$sessionId = $this->resolveDailySession($school, $scannedAt);
|
||||
|
||||
$existing = DB::table('attendance_records')
|
||||
->where('school_id', $school)
|
||||
->where('attendance_session_id', $sessionId)
|
||||
->where('subject_type', 'student')
|
||||
->where('subject_id', $student->id)
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
DB::table('attendance_records')->where('id', $existing->id)->update([
|
||||
'last_seen_at' => $scannedAt,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$recordId = (int) $existing->id;
|
||||
$statusResult = 'duplicate';
|
||||
} else {
|
||||
$recordId = (int) DB::table('attendance_records')->insertGetId([
|
||||
'school_id' => $school,
|
||||
'attendance_session_id' => $sessionId,
|
||||
'attendance_date' => $scannedAt->toDateString(),
|
||||
'subject_type' => 'student',
|
||||
'subject_id' => $student->id,
|
||||
'status' => 'present',
|
||||
'source' => $data['source'] ?? 'scan',
|
||||
'first_seen_at' => $scannedAt,
|
||||
'last_seen_at' => $scannedAt,
|
||||
'metadata' => json_encode(['student_number' => $student->school_id_number], JSON_THROW_ON_ERROR),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
$statusResult = 'recorded';
|
||||
}
|
||||
|
||||
$scanId = (int) DB::table('attendance_scan_logs')->insertGetId([
|
||||
'school_id' => $school,
|
||||
'attendance_record_id' => $recordId,
|
||||
'subject_type' => 'student',
|
||||
'subject_id' => $student->id,
|
||||
'station_id' => $data['station_id'] ?? null,
|
||||
'scan_action' => 'check_in',
|
||||
'scan_source' => $data['source'] ?? 'scan',
|
||||
'scanned_at' => $scannedAt,
|
||||
'status_result' => $statusResult,
|
||||
'raw_payload_json' => json_encode($data, JSON_THROW_ON_ERROR),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return $this->ok([
|
||||
'scan_id' => $scanId,
|
||||
'attendance_record_id' => $recordId,
|
||||
'student_id' => (int) $student->id,
|
||||
'status' => $statusResult,
|
||||
], $statusResult === 'recorded' ? Response::HTTP_CREATED : Response::HTTP_OK, 'Attendance scan processed.');
|
||||
}
|
||||
|
||||
public function previewCommunication(Request $request, int $school): JsonResponse
|
||||
{
|
||||
$this->assertSchoolExists($school);
|
||||
|
||||
$data = $request->validate([
|
||||
'template_key' => ['required', 'string', 'max:128'],
|
||||
'student_id' => ['required', 'integer'],
|
||||
'channel' => ['nullable', 'string', 'max:32'],
|
||||
]);
|
||||
|
||||
$student = $this->findStudent($school, (int) $data['student_id']);
|
||||
$template = $this->findTemplate($school, $data['template_key'], $data['channel'] ?? null);
|
||||
|
||||
return $this->ok([
|
||||
'template_key' => $template->template_key,
|
||||
'subject' => $this->renderTemplate($template->subject, $student),
|
||||
'body' => $this->renderTemplate($template->body, $student),
|
||||
'student_id' => (int) $student->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function sendCommunication(Request $request, int $school): JsonResponse
|
||||
{
|
||||
$this->assertSchoolExists($school);
|
||||
|
||||
$data = $request->validate([
|
||||
'template_key' => ['required', 'string', 'max:128'],
|
||||
'student_id' => ['required', 'integer'],
|
||||
'channel' => ['required', 'string', 'max:32'],
|
||||
]);
|
||||
|
||||
$student = $this->findStudent($school, (int) $data['student_id']);
|
||||
$template = $this->findTemplate($school, $data['template_key'], $data['channel']);
|
||||
|
||||
$messageId = (int) DB::table('communication_messages')->insertGetId([
|
||||
'school_id' => $school,
|
||||
'actor_user_id' => null,
|
||||
'channel' => $data['channel'],
|
||||
'message_category' => $template->message_category ?? 'general',
|
||||
'priority' => 'normal',
|
||||
'subject' => $this->renderTemplate($template->subject, $student),
|
||||
'body_snapshot' => $this->renderTemplate($template->body, $student),
|
||||
'template_id' => $template->id,
|
||||
'template_version' => $template->version ?? '1',
|
||||
'status' => 'queued',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$recipientId = (int) DB::table('communication_message_recipients')->insertGetId([
|
||||
'message_id' => $messageId,
|
||||
'school_id' => $school,
|
||||
'recipient_type' => 'student',
|
||||
'recipient_id' => $student->id,
|
||||
'channel' => $data['channel'],
|
||||
'status' => 'queued',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
return $this->ok([
|
||||
'message_id' => $messageId,
|
||||
'recipient_id' => $recipientId,
|
||||
'status' => 'queued',
|
||||
], Response::HTTP_ACCEPTED, 'Communication queued.');
|
||||
}
|
||||
|
||||
public function uploadPaymentFile(Request $request, int $school): JsonResponse
|
||||
{
|
||||
$this->assertSchoolExists($school);
|
||||
|
||||
$request->validate(['file' => ['required', 'file']]);
|
||||
|
||||
$file = $request->file('file');
|
||||
$rows = array_map('str_getcsv', file($file->getRealPath()) ?: []);
|
||||
$headers = array_map(static fn ($value): string => trim((string) $value), $rows[0] ?? []);
|
||||
$required = ['student_number', 'amount', 'paid_at', 'reference'];
|
||||
|
||||
if (array_diff($required, $headers) !== []) {
|
||||
return $this->fail('Invalid payment file.', Response::HTTP_UNPROCESSABLE_ENTITY, [
|
||||
'file' => ['CSV must include student_number, amount, paid_at, and reference columns.'],
|
||||
]);
|
||||
}
|
||||
|
||||
$imported = [];
|
||||
|
||||
try {
|
||||
return DB::transaction(function () use ($school, $headers, $rows, &$imported): JsonResponse {
|
||||
foreach (array_slice($rows, 1) as $row) {
|
||||
if ($row === [null] || $row === false || count(array_filter($row, static fn ($value) => $value !== null && $value !== '')) === 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$record = array_combine($headers, array_pad($row, count($headers), null));
|
||||
if (! $record || empty($record['student_number']) || ! is_numeric($record['amount']) || empty($record['paid_at']) || empty($record['reference'])) {
|
||||
throw new \InvalidArgumentException('Invalid payment row.');
|
||||
}
|
||||
|
||||
$student = DB::table('students')
|
||||
->where('school_id', $school)
|
||||
->where('school_id_number', $record['student_number'])
|
||||
->first();
|
||||
|
||||
if (! $student) {
|
||||
throw new \InvalidArgumentException('Payment row references an unknown student.');
|
||||
}
|
||||
|
||||
$paymentId = (int) DB::table('payments')->insertGetId([
|
||||
'school_id' => $school,
|
||||
'student_id' => $student->id,
|
||||
'amount_minor' => (int) round(((float) $record['amount']) * 100),
|
||||
'currency' => 'USD',
|
||||
'payment_method' => 'file_import',
|
||||
'payment_date' => $record['paid_at'],
|
||||
'reference_number' => $record['reference'],
|
||||
'status' => 'recorded',
|
||||
'metadata' => json_encode(['source' => 'payment_file'], JSON_THROW_ON_ERROR),
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$imported[] = $paymentId;
|
||||
}
|
||||
|
||||
return $this->ok([
|
||||
'imported_count' => count($imported),
|
||||
'payment_ids' => $imported,
|
||||
], Response::HTTP_CREATED, 'Payment file imported.');
|
||||
});
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
return $this->fail('Invalid payment file.', Response::HTTP_UNPROCESSABLE_ENTITY, [
|
||||
'file' => [$exception->getMessage()],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function dailyReport(Request $request, int $school): JsonResponse
|
||||
{
|
||||
$this->assertSchoolExists($school);
|
||||
|
||||
$date = (string) $request->query('date', now()->toDateString());
|
||||
|
||||
return $this->ok([
|
||||
'date' => $date,
|
||||
'attendance' => [
|
||||
'present_count' => DB::table('attendance_records')
|
||||
->where('school_id', $school)
|
||||
->where('attendance_date', $date)
|
||||
->where('status', 'present')
|
||||
->count(),
|
||||
],
|
||||
'finance' => [
|
||||
'total_payments' => (int) DB::table('payments')
|
||||
->where('school_id', $school)
|
||||
->where('payment_date', $date)
|
||||
->where('status', '!=', 'reversed')
|
||||
->sum('amount_minor'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
private function schoolPayload(int $school): array
|
||||
{
|
||||
$row = DB::table('schools')->where('id', $school)->first();
|
||||
|
||||
abort_if(! $row, Response::HTTP_NOT_FOUND, 'School not found.');
|
||||
|
||||
return [
|
||||
'id' => (int) $row->id,
|
||||
'name' => $row->name,
|
||||
'code' => $row->code ?? null,
|
||||
'timezone' => $row->timezone,
|
||||
'locale' => $row->locale,
|
||||
'currency' => $row->currency,
|
||||
];
|
||||
}
|
||||
|
||||
private function studentPayload(int $school, int $student): array
|
||||
{
|
||||
$row = $this->findStudent($school, $student);
|
||||
$metadata = json_decode((string) ($row->profile_metadata ?? $row->metadata ?? '{}'), true) ?: [];
|
||||
|
||||
return [
|
||||
'id' => (int) $row->id,
|
||||
'school_id' => (int) $row->school_id,
|
||||
'first_name' => $row->first_name,
|
||||
'last_name' => $row->last_name,
|
||||
'student_number' => $row->school_id_number ?? $row->student_identifier,
|
||||
'grade_level' => $metadata['grade_level'] ?? null,
|
||||
'status' => $row->status,
|
||||
];
|
||||
}
|
||||
|
||||
private function assertSchoolExists(int $school): void
|
||||
{
|
||||
abort_if(! DB::table('schools')->where('id', $school)->exists(), Response::HTTP_NOT_FOUND, 'School not found.');
|
||||
}
|
||||
|
||||
private function findStudent(int $school, int $student): object
|
||||
{
|
||||
$row = DB::table('students')->where('school_id', $school)->where('id', $student)->first();
|
||||
abort_if(! $row, Response::HTTP_NOT_FOUND, 'Student not found.');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function findStudentByScanInput(int $school, array $data): object
|
||||
{
|
||||
$query = DB::table('students')->where('school_id', $school);
|
||||
|
||||
if (isset($data['student_id'])) {
|
||||
$query->where('id', $data['student_id']);
|
||||
} else {
|
||||
$query->where('school_id_number', $data['student_number']);
|
||||
}
|
||||
|
||||
$row = $query->first();
|
||||
abort_if(! $row, Response::HTTP_NOT_FOUND, 'Student not found.');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function resolveDailySession(int $school, \DateTimeInterface $scannedAt): int
|
||||
{
|
||||
$date = $scannedAt->format('Y-m-d');
|
||||
$existing = DB::table('attendance_sessions')
|
||||
->where('school_id', $school)
|
||||
->whereDate('starts_at', $date)
|
||||
->where('session_type', 'daily')
|
||||
->first();
|
||||
|
||||
if ($existing) {
|
||||
return (int) $existing->id;
|
||||
}
|
||||
|
||||
return (int) DB::table('attendance_sessions')->insertGetId([
|
||||
'school_id' => $school,
|
||||
'name' => 'Daily attendance '.$date,
|
||||
'session_type' => 'daily',
|
||||
'starts_at' => $date.' 00:00:00',
|
||||
'ends_at' => $date.' 23:59:59',
|
||||
'timezone' => 'UTC',
|
||||
'status' => 'open',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function findTemplate(int $school, string $templateKey, ?string $channel): object
|
||||
{
|
||||
$query = DB::table('communication_templates')
|
||||
->where(function ($query) use ($school): void {
|
||||
$query->where('school_id', $school)->orWhereNull('school_id');
|
||||
})
|
||||
->where('template_key', $templateKey)
|
||||
->where('status', '!=', 'archived')
|
||||
->orderByDesc('school_id')
|
||||
->orderByDesc('version');
|
||||
|
||||
if ($channel !== null) {
|
||||
$query->where('channel', $channel);
|
||||
}
|
||||
|
||||
$row = $query->first();
|
||||
abort_if(! $row, Response::HTTP_NOT_FOUND, 'Communication template not found.');
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function renderTemplate(?string $template, object $student): ?string
|
||||
{
|
||||
if ($template === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return Str::of($template)
|
||||
->replace('{{ student.first_name }}', (string) $student->first_name)
|
||||
->replace('{{student.first_name}}', (string) $student->first_name)
|
||||
->replace('{{ student.last_name }}', (string) $student->last_name)
|
||||
->replace('{{student.last_name}}', (string) $student->last_name)
|
||||
->toString();
|
||||
}
|
||||
|
||||
private function ok(array $data, int $status = Response::HTTP_OK, ?string $message = null): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'data' => $data,
|
||||
'message' => $message,
|
||||
'errors' => null,
|
||||
], $status);
|
||||
}
|
||||
|
||||
private function fail(string $message, int $status, array $errors): JsonResponse
|
||||
{
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'data' => null,
|
||||
'message' => $message,
|
||||
'errors' => $errors,
|
||||
], $status);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\Contracts\ScannerServiceContract;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Http\Requests\Attendance\ProcessScanRequest;
|
||||
use App\Http\Resources\V2\Attendance\ScanResultResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class ScanController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly ScannerServiceContract $scanner) {}
|
||||
|
||||
public function store(ProcessScanRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->scanner->processScan($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success((new ScanResultResource($result))->resolve($request), 'Scan processed.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
abstract class BaseApiController extends Controller
|
||||
{
|
||||
public function __construct(protected readonly SchoolContextStore $schoolContext) {}
|
||||
|
||||
protected function context(): SchoolContext
|
||||
{
|
||||
return $this->schoolContext->current();
|
||||
}
|
||||
|
||||
protected function ok(mixed $data = null, ?string $message = null, array $meta = []): JsonResponse
|
||||
{
|
||||
return ApiResponse::success($data, $message, $meta);
|
||||
}
|
||||
|
||||
protected function created(mixed $data = null, ?string $message = null, array $meta = []): JsonResponse
|
||||
{
|
||||
return ApiResponse::success($data, $message, $meta, 201);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Communication;
|
||||
|
||||
use App\Domain\SchoolCore\Communication\Contracts\CommunicationServiceContract;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Http\Requests\Communication\BulkSendMessageRequest;
|
||||
use App\Http\Resources\V2\Communication\MessageResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class BulkSendController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly CommunicationServiceContract $communication) {}
|
||||
|
||||
public function store(BulkSendMessageRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->communication->sendBulkMessage($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success((new MessageResource($result))->resolve($request), 'Bulk message accepted.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Communication;
|
||||
|
||||
use App\Domain\SchoolCore\Communication\Contracts\RecipientPreviewServiceContract;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Http\Requests\Communication\RecipientPreviewRequest;
|
||||
use App\Http\Resources\V2\Communication\RecipientPreviewResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class RecipientPreviewController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly RecipientPreviewServiceContract $previews) {}
|
||||
|
||||
public function store(RecipientPreviewRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->previews->preview($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success((new RecipientPreviewResource($result))->resolve($request), 'Recipient preview created.', [], 201);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Domain\SchoolCore\Finance\Contracts\PaymentServiceContract;
|
||||
use App\Http\Requests\Finance\EditPaymentRequest;
|
||||
use App\Http\Requests\Finance\RecordPaymentRequest;
|
||||
use App\Http\Resources\V2\Finance\PaymentResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class PaymentController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly PaymentServiceContract $payments) {}
|
||||
|
||||
public function store(RecordPaymentRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->payments->recordPayment($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success((new PaymentResource($result))->resolve($request), 'Payment recorded.', [], 201);
|
||||
}
|
||||
|
||||
public function update(EditPaymentRequest $request, int $payment): JsonResponse
|
||||
{
|
||||
$result = $this->payments->editPayment($this->context->current(), $payment, $request->toDTO());
|
||||
return ApiResponse::success((new PaymentResource($result))->resolve($request), 'Payment updated.');
|
||||
}
|
||||
|
||||
public function reverse(EditPaymentRequest $request, int $payment): JsonResponse
|
||||
{
|
||||
$result = $this->payments->reversePayment($this->context->current(), $payment, (string) $request->validated('edit_reason', 'Reversed through API'));
|
||||
return ApiResponse::success((new PaymentResource($result))->resolve($request), 'Payment reversed.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Domain\SchoolCore\Finance\Contracts\FinanceFileServiceContract;
|
||||
use App\Http\Requests\Finance\DownloadPaymentFileRequest;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||
|
||||
final class PaymentFileController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly FinanceFileServiceContract $files) {}
|
||||
|
||||
public function show(DownloadPaymentFileRequest $request, int $payment): BinaryFileResponse
|
||||
{
|
||||
return $this->files->downloadPaymentFile($this->context->current(), $payment, (string) $request->validated('mode', 'download'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\IslamicSundaySchool;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ReportRunnerContract;
|
||||
use App\Domain\SchoolCore\Reporting\DTO\ReportRequestData;
|
||||
use App\Http\Resources\V2\IslamicSundaySchool\QuranProgressReportResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class QuranProgressController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly ReportRunnerContract $reports) {}
|
||||
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$data = new ReportRequestData('islamic.quran_progress', [], null, null, null, null, false, null, null, false, []);
|
||||
$result = $this->reports->run($this->context->current(), $data);
|
||||
return ApiResponse::success((new QuranProgressReportResource($result))->resolve(request()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Reporting;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ReportRegistryContract;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ReportRunnerContract;
|
||||
use App\Http\Requests\Reporting\ListReportsRequest;
|
||||
use App\Http\Requests\Reporting\RunReportRequest;
|
||||
use App\Http\Resources\V2\Reporting\ReportResultResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class ReportController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly ReportRegistryContract $registry, private readonly ReportRunnerContract $runner) {}
|
||||
|
||||
public function index(ListReportsRequest $request): JsonResponse
|
||||
{
|
||||
$reports = array_map(fn ($report) => [
|
||||
'key' => $report->key(),
|
||||
'name' => $report->name(),
|
||||
'category' => $report->category()->value,
|
||||
'visibility' => $report->visibility()->value,
|
||||
], $this->registry->availableReports($this->context->current()));
|
||||
|
||||
return ApiResponse::success($reports);
|
||||
}
|
||||
|
||||
public function run(RunReportRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->runner->run($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success((new ReportResultResource($result))->resolve($request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Reporting;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ReportExportServiceContract;
|
||||
use App\Http\Requests\Reporting\ExportReportRequest;
|
||||
use App\Http\Resources\V2\Reporting\ReportExportResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class ReportExportController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly ReportExportServiceContract $exports) {}
|
||||
|
||||
public function store(ExportReportRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->exports->export($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success((new ReportExportResource($result))->resolve($request), 'Report export created.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Api\V2\Students;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Domain\SchoolCore\Students\Contracts\StudentReadServiceContract;
|
||||
use App\Domain\SchoolCore\Students\Contracts\StudentServiceContract;
|
||||
use App\Http\Requests\Students\CreateStudentRequest;
|
||||
use App\Http\Requests\Students\StudentSearchRequest;
|
||||
use App\Http\Requests\Students\StudentStatusTransitionRequest;
|
||||
use App\Http\Requests\Students\UpdateStudentRequest;
|
||||
use App\Http\Resources\V2\Students\StudentResource;
|
||||
use App\Support\Api\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class StudentController extends Controller
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $context, private readonly StudentServiceContract $students, private readonly StudentReadServiceContract $reader) {}
|
||||
|
||||
public function index(StudentSearchRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->reader->search($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success($result);
|
||||
}
|
||||
|
||||
public function store(CreateStudentRequest $request): JsonResponse
|
||||
{
|
||||
$result = $this->students->createStudent($this->context->current(), $request->toDTO());
|
||||
return ApiResponse::success((new StudentResource($result))->resolve($request), 'Student created.', [], 201);
|
||||
}
|
||||
|
||||
public function show(int $student): JsonResponse
|
||||
{
|
||||
$result = $this->students->getStudent($this->context->current(), $student);
|
||||
return ApiResponse::success((new StudentResource($result))->resolve(request()));
|
||||
}
|
||||
|
||||
public function update(UpdateStudentRequest $request, int $student): JsonResponse
|
||||
{
|
||||
$result = $this->students->updateStudent($this->context->current(), $student, $request->toDTO());
|
||||
return ApiResponse::success((new StudentResource($result))->resolve($request), 'Student updated.');
|
||||
}
|
||||
|
||||
public function transition(StudentStatusTransitionRequest $request, int $student): JsonResponse
|
||||
{
|
||||
$result = $this->students->transitionStatus($this->context->current(), $student, $request->toDTO());
|
||||
return ApiResponse::success((new StudentResource($result))->resolve($request), 'Student status changed.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\Contracts\ScannerServiceContract;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Http\Requests\Attendance\ProcessScanRequest;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class ScannerController extends Controller
|
||||
{
|
||||
public function __construct(private ScannerServiceContract $scanner) {}
|
||||
|
||||
public function __invoke(ProcessScanRequest $request)
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
|
||||
$result = $this->scanner->processScan($context, $request->toDTO());
|
||||
|
||||
return response()->json($result->toArray());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\Contracts\StaffAttendanceServiceContract;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Http\Requests\Attendance\RecordStaffAttendanceRequest;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class StaffAttendanceController extends Controller
|
||||
{
|
||||
public function __construct(private StaffAttendanceServiceContract $staff) {}
|
||||
|
||||
public function store(RecordStaffAttendanceRequest $request)
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
$result = $this->staff->recordStaffAttendance($context, $request->toDTO());
|
||||
|
||||
return response()->json(['data' => $result]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\Contracts\StudentAttendanceServiceContract;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Http\Requests\Attendance\RecordStudentAttendanceRequest;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class StudentAttendanceController extends Controller
|
||||
{
|
||||
public function __construct(private StudentAttendanceServiceContract $students) {}
|
||||
|
||||
public function store(RecordStudentAttendanceRequest $request)
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
$result = $this->students->recordStudentAttendance($context, $request->toDTO());
|
||||
|
||||
return response()->json(['data' => $result]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<?php declare(strict_types=1); namespace App\Http\Controllers\Communication; use Illuminate\Routing\Controller; use App\Domain\SchoolCore\Communication\Contracts\CommunicationServiceContract; final class BulkMessageController extends Controller { public function __construct(private CommunicationServiceContract $messages) {} public function send(): array { return ['status'=>'delegated']; } }
|
||||
@@ -0,0 +1 @@
|
||||
<?php declare(strict_types=1); namespace App\Http\Controllers\Communication; use Illuminate\Routing\Controller; use App\Domain\SchoolCore\Communication\Contracts\MessageTemplateServiceContract; final class MessageTemplateController extends Controller { public function __construct(private MessageTemplateServiceContract $templates) {} public function store(): array { return ['status'=>'delegated']; } }
|
||||
@@ -0,0 +1 @@
|
||||
<?php declare(strict_types=1); namespace App\Http\Controllers\Communication; use Illuminate\Routing\Controller; use App\Domain\SchoolCore\Communication\Contracts\RecipientPreviewServiceContract; final class RecipientPreviewController extends Controller { public function __construct(private RecipientPreviewServiceContract $previews) {} public function store(): array { return ['status'=>'preview-required']; } }
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Controllers\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Finance\Contracts\FinanceFileServiceContract;
|
||||
use App\Http\Requests\Finance\DownloadPaymentFileRequest;
|
||||
|
||||
final class PaymentFileController
|
||||
{
|
||||
public function __construct(private readonly FinanceFileServiceContract $files) {}
|
||||
public function show(DownloadPaymentFileRequest $request, int $payment)
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
return $this->files->downloadPaymentFile($context, $payment, $request->mode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Reporting;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ReportRegistryContract;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ReportRunnerContract;
|
||||
use App\Http\Requests\Reporting\RunReportRequest;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class ReportController extends Controller
|
||||
{
|
||||
public function __construct(private readonly ReportRunnerContract $runner, private readonly ReportRegistryContract $registry) {}
|
||||
|
||||
public function index(RunReportRequest $request): array
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
return ['reports' => array_map(fn ($report) => ['key' => $report->key(), 'name' => $report->name()], $this->registry->availableReports($context))];
|
||||
}
|
||||
|
||||
public function run(RunReportRequest $request): array
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
$result = $this->runner->run($context, $request->toDTO());
|
||||
return ['data' => $result];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Reporting;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ReportExportServiceContract;
|
||||
use App\Http\Requests\Reporting\ExportReportRequest;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class ReportExportController extends Controller
|
||||
{
|
||||
public function __construct(private readonly ReportExportServiceContract $exports) {}
|
||||
public function export(ExportReportRequest $request): array
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
return ['export' => $this->exports->export($context, $request->toDTO())];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Reporting;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Reporting\Contracts\ScheduledReportServiceContract;
|
||||
use App\Http\Requests\Reporting\ScheduleReportRequest;
|
||||
use Illuminate\Routing\Controller;
|
||||
|
||||
final class ScheduledReportController extends Controller
|
||||
{
|
||||
public function __construct(private readonly ScheduledReportServiceContract $scheduled) {}
|
||||
public function store(ScheduleReportRequest $request): array
|
||||
{
|
||||
/** @var SchoolContext $context */
|
||||
$context = $request->attributes->get(SchoolContext::class);
|
||||
return ['scheduled_report' => $this->scheduled->schedule($context, $request->toDTO())];
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Students;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext; use App\Domain\SchoolCore\Students\Contracts\AssignmentServiceContract; use App\Http\Requests\Students\AssignmentRequest; use Illuminate\Http\Request; use Illuminate\Routing\Controller;
|
||||
final class AssignmentController extends Controller { public function __construct(private readonly AssignmentServiceContract $assignments){} public function store(AssignmentRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->assignments->assignStudent($context,$request->toDTO())]; } public function destroy(Request $request,int $assignment): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->assignments->unassignStudent($context,$assignment,(string)$request->input('reason','unassign student'))]; } }
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Students;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext; use App\Domain\SchoolCore\Students\Contracts\EnrollmentServiceContract; use App\Http\Requests\Students\EnrollmentRequest; use Illuminate\Http\Request; use Illuminate\Routing\Controller;
|
||||
final class EnrollmentController extends Controller { public function __construct(private readonly EnrollmentServiceContract $enrollments){} public function store(EnrollmentRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->enrollments->enrollStudent($context,$request->toDTO())]; } public function withdraw(Request $request,int $student): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->enrollments->withdrawStudent($context,$student,(string)$request->input('reason','withdrawal'))]; } }
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Students;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext; use App\Domain\SchoolCore\Students\Contracts\GuardianServiceContract; use App\Http\Requests\Students\CreateGuardianRequest; use App\Http\Requests\Students\LinkGuardianRequest; use Illuminate\Http\Request; use Illuminate\Routing\Controller;
|
||||
final class GuardianController extends Controller { public function __construct(private readonly GuardianServiceContract $guardians){} public function store(CreateGuardianRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->guardians->createGuardian($context,$request->toDTO())]; } public function link(LinkGuardianRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->guardians->linkGuardianToStudent($context,$request->toDTO())]; } public function unlink(Request $request,int $student,int $guardian): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->guardians->unlinkGuardianFromStudent($context,$student,$guardian,(string)$request->input('reason','unlink guardian'))]; } }
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Students;
|
||||
use App\Domain\IslamicSundaySchool\Students\Services\IslamicSundaySchoolStudentProfileService; use App\Domain\SchoolCore\Context\SchoolContext; use App\Http\Requests\Students\IslamicSundaySchoolStudentProfileRequest; use Illuminate\Routing\Controller;
|
||||
final class IslamicSundaySchoolStudentProfileController extends Controller { public function __construct(private readonly IslamicSundaySchoolStudentProfileService $profiles){} public function store(IslamicSundaySchoolStudentProfileRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->profiles->save($context,$request->toDTO())]; } }
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Students;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext; use App\Domain\SchoolCore\Students\Contracts\PromotionServiceContract; use App\Http\Requests\Students\BulkPromotionRequest; use App\Http\Requests\Students\PromotionRequest; use Illuminate\Http\Request; use Illuminate\Routing\Controller;
|
||||
final class PromotionController extends Controller { public function __construct(private readonly PromotionServiceContract $promotions){} public function evaluate(Request $request,int $student): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->promotions->evaluatePromotion($context,$student)]; } public function promote(PromotionRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->promotions->promoteStudent($context,$request->toDTO())]; } public function bulk(BulkPromotionRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->promotions->bulkPromote($context,$request->toDTO())]; } }
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Controllers\Students;
|
||||
use App\Domain\SchoolCore\Context\SchoolContext; use App\Domain\SchoolCore\Students\Contracts\StudentReadServiceContract; use App\Domain\SchoolCore\Students\Contracts\StudentServiceContract; use App\Http\Requests\Students\CreateStudentRequest; use App\Http\Requests\Students\StudentSearchRequest; use App\Http\Requests\Students\StudentStatusTransitionRequest; use App\Http\Requests\Students\UpdateStudentRequest; use Illuminate\Routing\Controller;
|
||||
final class StudentLifecycleController extends Controller { public function __construct(private readonly StudentServiceContract $students, private readonly StudentReadServiceContract $reads){} public function store(CreateStudentRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->students->createStudent($context,$request->toDTO())]; } public function show(CreateStudentRequest $request,int $student): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->students->getStudent($context,$student)]; } public function update(UpdateStudentRequest $request,int $student): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->students->updateStudent($context,$student,$request->toDTO())]; } public function transition(StudentStatusTransitionRequest $request,int $student): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->students->transitionStatus($context,$student,$request->toDTO())]; } public function index(StudentSearchRequest $request): array { $context=$request->attributes->get(SchoolContext::class); return ['data'=>$this->reads->search($context,$request->toDTO())]; } }
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class DeprecationHeaders
|
||||
{
|
||||
public function handle(Request $request, Closure $next, ?string $sunset = null, ?string $successor = null): Response
|
||||
{
|
||||
$response = $next($request);
|
||||
$response->headers->set('Deprecation', 'true');
|
||||
|
||||
if ($sunset) {
|
||||
$response->headers->set('Sunset', $sunset);
|
||||
}
|
||||
|
||||
if ($successor) {
|
||||
$response->headers->set('Link', sprintf('<%s>; rel="successor-version"', $successor));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class EnsureDomainProfile
|
||||
{
|
||||
public function __construct(private readonly SchoolContextStore $store) {}
|
||||
|
||||
public function handle(Request $request, Closure $next, string $profile): Response
|
||||
{
|
||||
/** @var SchoolContext|null $context */
|
||||
$context = $request->attributes->get(SchoolContext::class) ?? $this->store->current();
|
||||
|
||||
if (! $context || $context->domainProfile !== $profile) {
|
||||
abort(403, 'This route is not available for the current school domain profile.');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class EnsureSchoolAccess
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
if (! $user) {
|
||||
abort(401);
|
||||
}
|
||||
|
||||
$schoolId = $this->schoolIdFromRoute($request);
|
||||
|
||||
if (! $schoolId) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
if (! $this->userCanAccessSchool((int) $user->getAuthIdentifier(), $schoolId)) {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
private function schoolIdFromRoute(Request $request): ?int
|
||||
{
|
||||
$school = $request->route('school');
|
||||
|
||||
if (is_numeric($school)) {
|
||||
return (int) $school;
|
||||
}
|
||||
|
||||
if (is_object($school) && isset($school->id)) {
|
||||
return (int) $school->id;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private function userCanAccessSchool(int $userId, int $schoolId): bool
|
||||
{
|
||||
if (Schema::hasTable('school_user')) {
|
||||
return DB::table('school_user')
|
||||
->where('user_id', $userId)
|
||||
->where('school_id', $schoolId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
if (Schema::hasTable('school_users')) {
|
||||
return DB::table('school_users')
|
||||
->where('user_id', $userId)
|
||||
->where('school_id', $schoolId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
if (Schema::hasTable('users') && Schema::hasColumn('users', 'school_id')) {
|
||||
return DB::table('users')
|
||||
->where('id', $userId)
|
||||
->where('school_id', $schoolId)
|
||||
->exists();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Domain\SchoolCore\Context\SchoolContext;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextException;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextResolver;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextStore;
|
||||
use App\Domain\SchoolCore\Context\SchoolContextValidator;
|
||||
use Closure;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class ResolveSchoolContext
|
||||
{
|
||||
public function __construct(
|
||||
private readonly SchoolContextResolver $resolver,
|
||||
private readonly SchoolContextValidator $validator,
|
||||
private readonly SchoolContextStore $store,
|
||||
) {
|
||||
}
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
try {
|
||||
$context = $this->resolver->resolve($request);
|
||||
$this->validator->assertValid($context, $request->user());
|
||||
$this->store->set($context);
|
||||
$request->attributes->set(SchoolContext::class, $context);
|
||||
|
||||
return $next($request);
|
||||
} catch (SchoolContextException $exception) {
|
||||
return new JsonResponse([
|
||||
'message' => $exception->getMessage(),
|
||||
], $this->statusCodeFor($exception));
|
||||
} finally {
|
||||
// Avoid context bleeding in long-running workers such as Octane.
|
||||
$this->store->forget();
|
||||
}
|
||||
}
|
||||
|
||||
private function statusCodeFor(SchoolContextException $exception): int
|
||||
{
|
||||
$code = $exception->getCode();
|
||||
|
||||
return in_array($code, [401, 403, 422, 500], true) ? $code : 422;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Attendance;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class AttendanceSessionRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => ['required', 'string'],
|
||||
'session_type' => ['required', 'string'],
|
||||
'starts_at' => ['required', 'date'],
|
||||
'ends_at' => ['required', 'date', 'after:starts_at'],
|
||||
'timezone' => ['nullable', 'timezone'],
|
||||
'metadata' => ['nullable', 'array'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\DTO\AttendanceSummaryQuery;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class AttendanceSummaryRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'from_date' => ['nullable', 'date'],
|
||||
'to_date' => ['nullable', 'date'],
|
||||
'session_id' => ['nullable', 'integer'],
|
||||
'subject_type' => ['nullable', 'string'],
|
||||
];
|
||||
}
|
||||
|
||||
public function toDTO(): AttendanceSummaryQuery
|
||||
{
|
||||
$validated = $this->validated();
|
||||
return new AttendanceSummaryQuery(
|
||||
fromDate: $validated['from_date'] ?? null,
|
||||
toDate: $validated['to_date'] ?? null,
|
||||
sessionId: isset($validated['session_id']) ? (int) $validated['session_id'] : null,
|
||||
subjectType: $validated['subject_type'] ?? null,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Attendance;
|
||||
|
||||
final class ManualStaffAttendanceOverrideRequest extends RecordStaffAttendanceRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return parent::rules() + [
|
||||
'override_reason' => ['required', 'string', 'min:3'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Attendance;
|
||||
|
||||
final class ManualStudentAttendanceOverrideRequest extends RecordStudentAttendanceRequest
|
||||
{
|
||||
public function rules(): array
|
||||
{
|
||||
return parent::rules() + [
|
||||
'override_reason' => ['required', 'string', 'min:3'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\DTO\ProcessScanData;
|
||||
use DateTimeImmutable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class ProcessScanRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'badge_value' => ['required', 'string', 'max:191'],
|
||||
'station_id' => ['nullable', 'string', 'max:191'],
|
||||
'scan_action' => ['nullable', 'string', 'in:check_in,check_out,lookup'],
|
||||
'scan_source' => ['nullable', 'string', 'in:scanner,manual,api'],
|
||||
'scanned_at' => ['nullable', 'date'],
|
||||
'device_id' => ['nullable', 'string', 'max:191'],
|
||||
'client_request_id' => ['nullable', 'string', 'max:191'],
|
||||
'idempotency_key' => ['nullable', 'string', 'max:191'],
|
||||
'metadata' => ['nullable', 'array'],
|
||||
];
|
||||
}
|
||||
|
||||
public function toDTO(): ProcessScanData
|
||||
{
|
||||
$validated = $this->validated();
|
||||
|
||||
return new ProcessScanData(
|
||||
badgeValue: (string) $validated['badge_value'],
|
||||
stationId: $validated['station_id'] ?? null,
|
||||
scanAction: $validated['scan_action'] ?? 'check_in',
|
||||
scanSource: $validated['scan_source'] ?? 'scanner',
|
||||
scannedAt: new DateTimeImmutable($validated['scanned_at'] ?? 'now'),
|
||||
deviceId: $validated['device_id'] ?? null,
|
||||
clientRequestId: $validated['client_request_id'] ?? null,
|
||||
idempotencyKey: $validated['idempotency_key'] ?? null,
|
||||
metadata: $validated['metadata'] ?? [],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\DTO\RecordStaffAttendanceData;
|
||||
use DateTimeImmutable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class RecordStaffAttendanceRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'staff_id' => ['required', 'integer'],
|
||||
'session_id' => ['nullable', 'integer'],
|
||||
'attendance_date' => ['required', 'date'],
|
||||
'status' => ['required', 'string'],
|
||||
'source' => ['nullable', 'string'],
|
||||
'recorded_at' => ['nullable', 'date'],
|
||||
'reason' => ['nullable', 'string'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
'override_reason' => ['nullable', 'string'],
|
||||
'idempotency_key' => ['nullable', 'string'],
|
||||
'metadata' => ['nullable', 'array'],
|
||||
];
|
||||
}
|
||||
|
||||
public function toDTO(): RecordStaffAttendanceData
|
||||
{
|
||||
$validated = $this->validated();
|
||||
|
||||
return new RecordStaffAttendanceData(
|
||||
staffId: (int) $validated['staff_id'],
|
||||
sessionId: isset($validated['session_id']) ? (int) $validated['session_id'] : null,
|
||||
attendanceDate: (string) $validated['attendance_date'],
|
||||
status: (string) $validated['status'],
|
||||
source: $validated['source'] ?? 'manual',
|
||||
recordedAt: new DateTimeImmutable($validated['recorded_at'] ?? 'now'),
|
||||
reason: $validated['reason'] ?? null,
|
||||
notes: $validated['notes'] ?? null,
|
||||
overrideReason: $validated['override_reason'] ?? null,
|
||||
idempotencyKey: $validated['idempotency_key'] ?? null,
|
||||
metadata: $validated['metadata'] ?? [],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Attendance;
|
||||
|
||||
use App\Domain\SchoolCore\Attendance\DTO\RecordStudentAttendanceData;
|
||||
use DateTimeImmutable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class RecordStudentAttendanceRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'student_id' => ['required', 'integer'],
|
||||
'session_id' => ['nullable', 'integer'],
|
||||
'attendance_date' => ['required', 'date'],
|
||||
'status' => ['required', 'string'],
|
||||
'source' => ['nullable', 'string'],
|
||||
'recorded_at' => ['nullable', 'date'],
|
||||
'reason' => ['nullable', 'string'],
|
||||
'notes' => ['nullable', 'string'],
|
||||
'override_reason' => ['nullable', 'string'],
|
||||
'idempotency_key' => ['nullable', 'string'],
|
||||
'metadata' => ['nullable', 'array'],
|
||||
];
|
||||
}
|
||||
|
||||
public function toDTO(): RecordStudentAttendanceData
|
||||
{
|
||||
$validated = $this->validated();
|
||||
|
||||
return new RecordStudentAttendanceData(
|
||||
studentId: (int) $validated['student_id'],
|
||||
sessionId: isset($validated['session_id']) ? (int) $validated['session_id'] : null,
|
||||
attendanceDate: (string) $validated['attendance_date'],
|
||||
status: (string) $validated['status'],
|
||||
source: $validated['source'] ?? 'manual',
|
||||
recordedAt: new DateTimeImmutable($validated['recorded_at'] ?? 'now'),
|
||||
reason: $validated['reason'] ?? null,
|
||||
notes: $validated['notes'] ?? null,
|
||||
overrideReason: $validated['override_reason'] ?? null,
|
||||
idempotencyKey: $validated['idempotency_key'] ?? null,
|
||||
metadata: $validated['metadata'] ?? [],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class BulkSendMessageRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class CancelScheduledMessageRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class CreateMessageTemplateRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class DeliveryReceiptRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class RecipientPreviewRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class ScheduleMessageRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class SendMessageRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class UpdateCommunicationPreferenceRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Communication;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class UpdateMessageTemplateRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): array { return $this->validated(); } }
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class DownloadPaymentFileRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['mode'=>['nullable','string','in:download,view']]; }
|
||||
public function mode(): string { return (string) ($this->validated('mode') ?: 'download'); }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Finance\DTO\EditPaymentData;
|
||||
use App\Domain\SchoolCore\Finance\DTO\MoneyData;
|
||||
use App\Domain\SchoolCore\Finance\Enums\PaymentMethod;
|
||||
use DateTimeImmutable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class EditPaymentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['amount_minor'=>['nullable','integer','min:1'],'currency'=>['required_with:amount_minor','string','size:3'],'payment_method'=>['nullable','string','in:cash,check,card,bank_transfer,other'],'payment_date'=>['nullable','date'],'reference_number'=>['nullable','string'],'notes'=>['nullable','string'],'replacement_file'=>['nullable','file','max:10240'],'edit_reason'=>['required','string']]; }
|
||||
public function toDTO(): EditPaymentData { $v=$this->validated(); return new EditPaymentData(isset($v['amount_minor']) ? new MoneyData((int)$v['amount_minor'], strtoupper($v['currency'])) : null, isset($v['payment_method']) ? PaymentMethod::from($v['payment_method']) : null, isset($v['payment_date']) ? new DateTimeImmutable($v['payment_date']) : null, $v['reference_number'] ?? null, $v['notes'] ?? null, $this->file('replacement_file'), $v['edit_reason']); }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Finance\DTO\MoneyData;
|
||||
use App\Domain\SchoolCore\Finance\DTO\RecordPaymentData;
|
||||
use App\Domain\SchoolCore\Finance\Enums\PaymentMethod;
|
||||
use DateTimeImmutable;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class RecordPaymentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['invoice_id'=>['required','integer','min:1'],'amount_minor'=>['required','integer','min:1'],'currency'=>['required','string','size:3'],'payment_method'=>['required','string','in:cash,check,card,bank_transfer,other'],'payment_date'=>['required','date'],'student_id'=>['nullable','integer'],'guardian_id'=>['nullable','integer'],'reference_number'=>['nullable','string'],'notes'=>['nullable','string'],'idempotency_key'=>['nullable','string'],'uploaded_file'=>['nullable','file','max:10240']]; }
|
||||
public function toDTO(): RecordPaymentData { $v=$this->validated(); return new RecordPaymentData((int)$v['invoice_id'], isset($v['student_id'])?(int)$v['student_id']:null, isset($v['guardian_id'])?(int)$v['guardian_id']:null, new MoneyData((int)$v['amount_minor'], strtoupper($v['currency'])), PaymentMethod::from($v['payment_method']), new DateTimeImmutable($v['payment_date']), $v['reference_number'] ?? null, $v['notes'] ?? null, $v['idempotency_key'] ?? null, $this->file('uploaded_file')); }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Finance;
|
||||
|
||||
use App\Domain\SchoolCore\Finance\DTO\MoneyData;
|
||||
use App\Domain\SchoolCore\Finance\DTO\RefundPaymentData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class RefundPaymentRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['payment_id'=>['required','integer','min:1'],'amount_minor'=>['required','integer','min:1'],'currency'=>['required','string','size:3'],'reason'=>['required','string'],'idempotency_key'=>['nullable','string']]; }
|
||||
public function toDTO(): RefundPaymentData { $v=$this->validated(); return new RefundPaymentData((int)$v['payment_id'], new MoneyData((int)$v['amount_minor'], strtoupper($v['currency'])), $v['reason'], $v['idempotency_key'] ?? null); }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Reporting;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class CancelScheduledReportRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } }
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Reporting;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use App\Domain\SchoolCore\Reporting\DTO\ReportExportData;
|
||||
|
||||
final class ExportReportRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['report_key' => ['required','string'], 'filters' => ['sometimes','array'], 'columns' => ['sometimes','array']]; }
|
||||
public function toDTO(): ReportExportData { return new ReportExportData((string) $this->input('report_key'), $this->input('filters', []), $this->input('columns'), (string) $this->input('format', 'csv'), $this->input('snapshot_id'), $this->input('filename'), (bool) $this->input('include_sensitive_columns', false), $this->input('idempotency_key'), $this->input('metadata', [])); }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Requests\Reporting;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
final class ListReportsRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return []; }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Reporting;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use App\Domain\SchoolCore\Reporting\DTO\ReportRequestData;
|
||||
|
||||
final class RunReportRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['report_key' => ['required','string'], 'filters' => ['sometimes','array'], 'columns' => ['sometimes','array']]; }
|
||||
public function toDTO(): ReportRequestData { return new ReportRequestData((string) $this->input('report_key'), $this->input('filters', []), $this->input('columns'), $this->input('sorts'), $this->input('page'), $this->input('per_page'), (bool) $this->input('include_totals', false), $this->input('timezone'), $this->input('locale'), (bool) $this->input('snapshot', false), $this->input('metadata', [])); }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Reporting;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use App\Domain\SchoolCore\Reporting\DTO\ScheduledReportData;
|
||||
|
||||
final class ScheduleReportRequest extends FormRequest
|
||||
{
|
||||
public function authorize(): bool { return true; }
|
||||
public function rules(): array { return ['report_key' => ['required','string'], 'filters' => ['sometimes','array'], 'columns' => ['sometimes','array']]; }
|
||||
public function toDTO(): ScheduledReportData { return new ScheduledReportData((string) $this->input('report_key'), $this->input('filters', []), $this->input('columns'), (string) $this->input('format', 'csv'), (string) $this->input('frequency', 'weekly'), (string) $this->input('run_at'), $this->input('recipient_user_ids', []), $this->input('recipient_emails'), $this->input('expires_at'), $this->input('metadata', [])); }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
<?php declare(strict_types=1);
|
||||
namespace App\Http\Requests\Reporting;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class ViewReportSnapshotRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\AssignmentData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class AssignmentRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): AssignmentData { return new AssignmentData(studentId:(int)$this->input('student_id'), assignmentType:(string)$this->input('assignment_type'), assignableType:(string)$this->input('assignable_type'), assignableId:(int)$this->input('assignable_id'), effectiveFrom:(string)$this->input('effective_from',date('Y-m-d')), effectiveTo:$this->input('effective_to'), status:(string)$this->input('status','active'), metadata:(array)$this->input('metadata',[])); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\BulkPromotionData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class BulkPromotionRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): BulkPromotionData { return new BulkPromotionData(studentIds:(array)$this->input('student_ids',[]), fromAcademicYearId:(int)$this->input('from_academic_year_id'), toAcademicYearId:(int)$this->input('to_academic_year_id'), effectiveDate:(string)$this->input('effective_date',date('Y-m-d')), overridePolicy:(bool)$this->boolean('override_policy'), overrideReason:$this->input('override_reason')); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\CreateGuardianData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class CreateGuardianRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): CreateGuardianData { return new CreateGuardianData(firstName:(string)$this->input('first_name'), lastName:(string)$this->input('last_name'), email:$this->input('email'), phone:$this->input('phone'), relationshipType:$this->input('relationship_type'), emergencyContact:(bool)$this->boolean('emergency_contact'), pickupAuthorized:(bool)$this->boolean('pickup_authorized'), metadata:(array)$this->input('metadata',[])); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\HouseholdData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class CreateHouseholdRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): HouseholdData { return new HouseholdData(name:(string)$this->input('name'), primaryAddress:$this->input('primary_address'), metadata:(array)$this->input('metadata',[])); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\CreateStudentData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class CreateStudentRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): CreateStudentData { return new CreateStudentData(firstName:(string)$this->input('first_name'), lastName:(string)$this->input('last_name'), middleName:$this->input('middle_name'), preferredName:$this->input('preferred_name'), dateOfBirth:$this->input('date_of_birth'), gender:$this->input('gender'), primaryLanguage:$this->input('primary_language'), externalId:$this->input('external_id'), initialStatus:(string)$this->input('initial_status','active'), profileMetadata:(array)$this->input('profile_metadata',[]), extensionProfile:(array)$this->input('extension_profile',[]), idempotencyKey:$this->header('Idempotency-Key')); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\EnrollmentData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class EnrollmentRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): EnrollmentData { return new EnrollmentData(studentId:(int)$this->input('student_id'), academicYearId:(int)$this->input('academic_year_id'), termId:$this->input('term_id')?(int)$this->input('term_id'):null, gradeLevelId:$this->input('grade_level_id')?(int)$this->input('grade_level_id'):null, programId:$this->input('program_id')?(int)$this->input('program_id'):null, classGroupId:$this->input('class_group_id')?(int)$this->input('class_group_id'):null, enrollmentDate:(string)$this->input('enrollment_date',date('Y-m-d')), status:(string)$this->input('status','active'), reason:$this->input('reason'), metadata:(array)$this->input('metadata',[])); } }
|
||||
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\IslamicSundaySchool\Students\DTO\IslamicSundaySchoolStudentProfileData; use Illuminate\Foundation\Http\FormRequest;
|
||||
final class IslamicSundaySchoolStudentProfileRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): IslamicSundaySchoolStudentProfileData { return new IslamicSundaySchoolStudentProfileData(studentId:(int)$this->input('student_id'), familyProfileId:$this->input('family_profile_id')?(int)$this->input('family_profile_id'):null, quranLevelId:$this->input('quran_level_id')?(int)$this->input('quran_level_id'):null, arabicLevelId:$this->input('arabic_level_id')?(int)$this->input('arabic_level_id'):null, islamicStudiesTrackId:$this->input('islamic_studies_track_id')?(int)$this->input('islamic_studies_track_id'):null, halaqaGroupId:$this->input('halaqa_group_id')?(int)$this->input('halaqa_group_id'):null, memorizationProgressSummary:$this->input('memorization_progress_summary'), recitationPlacement:$this->input('recitation_placement'), volunteerFamilyParticipation:(bool)$this->boolean('volunteer_family_participation'), sensitiveAdminNotes:$this->input('sensitive_admin_notes'), metadata:(array)$this->input('metadata',[])); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\LinkGuardianData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class LinkGuardianRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): LinkGuardianData { return new LinkGuardianData(studentId:(int)$this->input('student_id'), guardianId:(int)$this->input('guardian_id'), relationshipType:(string)$this->input('relationship_type'), emergencyContact:(bool)$this->boolean('emergency_contact'), pickupAuthorized:(bool)$this->boolean('pickup_authorized'), financialResponsibility:$this->has('financial_responsibility')?(bool)$this->boolean('financial_responsibility'):null, academicContact:$this->has('academic_contact')?(bool)$this->boolean('academic_contact'):null, notes:$this->input('notes')); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\PromotionData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class PromotionRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): PromotionData { return new PromotionData(studentId:(int)$this->input('student_id'), fromAcademicYearId:(int)$this->input('from_academic_year_id'), toAcademicYearId:(int)$this->input('to_academic_year_id'), effectiveDate:(string)$this->input('effective_date',date('Y-m-d')), reason:(string)$this->input('reason','promotion'), overridePolicy:(bool)$this->boolean('override_policy'), overrideReason:$this->input('override_reason')); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\StudentSearchQuery;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class StudentSearchRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): StudentSearchQuery { return new StudentSearchQuery(search:$this->input('search'), status:$this->input('status','active'), guardianId:$this->input('guardian_id')?(int)$this->input('guardian_id'):null, householdId:$this->input('household_id')?(int)$this->input('household_id'):null, limit:(int)$this->input('limit',50), filters:(array)$this->input('filters',[])); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\StudentStatusTransitionData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class StudentStatusTransitionRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): StudentStatusTransitionData { return new StudentStatusTransitionData(fromStatus:(string)$this->input('from_status'), toStatus:(string)$this->input('to_status'), reason:(string)$this->input('reason'), metadata:(array)$this->input('metadata',[])); } }
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace App\Http\Requests\Students;
|
||||
use App\Domain\SchoolCore\Students\DTO\UpdateStudentData;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
final class UpdateStudentRequest extends FormRequest { public function authorize(): bool { return true; } public function rules(): array { return []; } public function toDTO(): UpdateStudentData { return new UpdateStudentData(firstName:$this->input('first_name'), lastName:$this->input('last_name'), middleName:$this->input('middle_name'), preferredName:$this->input('preferred_name'), dateOfBirth:$this->input('date_of_birth'), gender:$this->input('gender'), primaryLanguage:$this->input('primary_language'), profileMetadata:(array)$this->input('profile_metadata',[]), updateReason:(string)$this->input('update_reason','student update')); } }
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Attendance;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class AttendanceRecordResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Attendance;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class ScanResultResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Communication;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class MessageResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Communication;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class RecipientPreviewResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Finance;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class InvoiceResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Finance;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class PaymentResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\IslamicSundaySchool;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class IslamicSundaySchoolStudentProfileResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\IslamicSundaySchool;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class QuranProgressReportResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Reporting;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class ReportExportResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Reporting;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class ReportResultResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Students;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class EnrollmentResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Students;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class GuardianResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace App\Http\Resources\V2\Students;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
final class StudentResource extends JsonResource
|
||||
{
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
$value = $this->resource;
|
||||
if (is_array($value)) {
|
||||
return $value;
|
||||
}
|
||||
if (is_object($value) && method_exists($value, 'toArray')) {
|
||||
return $value->toArray();
|
||||
}
|
||||
if (is_object($value)) {
|
||||
return get_object_vars($value);
|
||||
}
|
||||
return ['value' => $value];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user