*/ public function schema(JsonSchema $schema): array { return [ 'from' => $schema->string()->description('Start date, YYYY-MM-DD.')->required(), 'to' => $schema->string()->description('End date, YYYY-MM-DD.')->required(), 'granularity' => $schema->string()->enum(['monthly', 'daily'])->description('Evolution granularity (default monthly).'), ]; } protected function respond(Request $request, User $user): Response { $request->validate([ 'from' => ['required', 'date'], 'to' => ['required', 'date'], 'granularity' => ['sometimes', 'in:monthly,daily'], ]); $controller = app(DashboardAnalyticsController::class); $range = ['from' => $request->string('from')->toString(), 'to' => $request->string('to')->toString()]; $daily = $request->string('granularity')->toString() === 'daily'; return $this->json([ 'granularity' => $daily ? 'daily' : 'monthly', 'current' => $this->callController($controller, 'netWorth', $user, $range), 'evolution' => $this->callController( $controller, $daily ? 'netWorthDailyEvolution' : 'netWorthEvolution', $user, $range, ), ]); } }