*/ public function schema(JsonSchema $schema): array { return []; } protected function respond(Request $request, User $user): Response { // ponytail: two extra queries per budget (its current period, and that // period's spend). Fine for the handful of budgets a user keeps; eager // load the current period with a sum if anyone ever runs dozens. $budgets = $user->budgets() ->with(['categories:id,name', 'labels:id,name']) ->orderBy('name') ->get() ->map(fn (Budget $budget): array => $this->presentBudget($budget)) ->all(); return $this->json([ 'currency' => $user->currency_code ?? 'USD', 'budgets' => $budgets, ]); } }