validated(); $payment = $this->planService->createPlan($payload); return response()->json([ 'ok' => true, 'payment' => new PaymentResource($payment), ], 201); } public function byParent(PaymentByParentRequest $request, int $parentId): JsonResponse { $payload = $request->validated(); $payments = $this->lookupService->getByParent($parentId, $payload['school_year'] ?? null); return response()->json([ 'ok' => true, 'payments' => PaymentResource::collection($payments), ]); } public function updateBalance(PaymentUpdateBalanceRequest $request, int $paymentId): JsonResponse { $payload = $request->validated(); $updated = $this->balanceService->updateBalance($paymentId, (float) $payload['paid_amount']); if (!$updated) { return response()->json(['ok' => false, 'message' => 'Payment not found.'], 404); } return response()->json(['ok' => true]); } }