validated(); $data = $this->service->listCharges($payload['school_year'] ?? null, $payload['semester'] ?? null); return response()->json(['ok' => true] + $data); } public function store(PaymentEventChargesStoreRequest $request): JsonResponse { $payload = $request->validated(); $userId = (int) (auth()->id() ?? 0); $count = $this->service->addCharges($payload, $userId); if ($count === 0) { return response()->json(['ok' => false, 'message' => 'No student selected.'], 422); } return response()->json(['ok' => true, 'inserted' => $count]); } public function enrolledStudents(PaymentEventChargesListRequest $request, int $parentId): JsonResponse { $payload = $request->validated(); $students = $this->service->getEnrolledStudents($parentId, $payload['school_year'] ?? null); return response()->json(['ok' => true, 'students' => $students]); } }