ordered()->get(); return ProjectResource::collection($projects) ->additional(['meta' => ['lang' => app()->getLocale()]]); } public function show(string $slug) { $project = Project::with('skills')->where('slug', $slug)->first(); if (!$project) { return response()->json([ 'error' => [ 'code' => 'PROJECT_NOT_FOUND', 'message' => 'Project not found', ], ], 404); } $lang = app()->getLocale(); // Get all projects in order for navigation $allProjects = Project::ordered()->get(['id', 'slug', 'title_key']); $currentIndex = $allProjects->search(fn ($p) => $p->slug === $slug); $prev = $currentIndex > 0 ? $allProjects[$currentIndex - 1] : null; $next = $currentIndex < $allProjects->count() - 1 ? $allProjects[$currentIndex + 1] : null; return (new ProjectResource($project)) ->additional([ 'meta' => ['lang' => $lang], 'navigation' => [ 'prev' => $prev ? [ 'slug' => $prev->slug, 'title' => Translation::getTranslation($prev->title_key, $lang), ] : null, 'next' => $next ? [ 'slug' => $next->slug, 'title' => Translation::getTranslation($next->title_key, $lang), ] : null, ], ]); } }