authorize('panel.access'); $findings = $report->runFor($request->user()); return response()->json([ 'data' => $findings->map(fn (Finding $finding) => [ 'key' => $finding->key, 'severity' => $finding->severity->value, 'count' => $finding->count, 'title' => $finding->title(), 'description' => $finding->description(), 'samples' => $finding->samples, 'panel_url' => $finding->url, ])->values(), 'meta' => [ 'problems' => $findings->filter(fn (Finding $f) => $f->severity->isProblem())->count(), 'checked_at' => now()->toIso8601String(), ], ]); } /** * Records with a language still to write (`missing`) or left behind by the * one it was translated from (`stale`, with since when). * * Filters: locale (only what that language lacks), type, published (only * what is on the site — open, for calls). */ public function translations(Request $request): JsonResponse { $locales = array_keys((array) config('locales.supported')); $request->validate([ 'locale' => ['sometimes', Rule::in($locales)], 'type' => ['sometimes', Rule::in(['pages', 'projects', 'services', 'calls'])], 'published' => ['sometimes', 'boolean'], ]); $items = PendingTranslations::find( $request->user(), $request->input('locale'), $request->input('type'), $request->boolean('published'), )->map(fn (array $item) => [ 'type' => $item['type'], 'id' => $item['id'], 'title' => $item['title'], 'missing' => $item['missing'], 'stale' => (object) collect($item['stale'])->map(fn ($since) => $since->toIso8601String())->all(), ]); return response()->json(['data' => $items->values()]); } }