active() ->forAccessLevel() ->pinned() ->orderBy('display_order') ->limit(5) ->get(); // Latest articles by type $latestBlog = Article::with(['categories']) ->active() ->forAccessLevel() ->byContentType('blog') ->orderByDesc('published_at') ->limit(6) ->get(); $latestNotice = Article::with(['categories']) ->active() ->forAccessLevel() ->byContentType('notice') ->orderByDesc('published_at') ->limit(4) ->get(); $latestDocument = Article::with(['categories']) ->active() ->forAccessLevel() ->byContentType('document') ->orderByDesc('published_at') ->limit(4) ->get(); $latestRelatedNews = Article::with(['categories']) ->active() ->forAccessLevel() ->byContentType('related_news') ->orderByDesc('published_at') ->limit(4) ->get(); // About page $aboutPage = Page::published() ->where('slug', 'about') ->first(); // Categories $categories = ArticleCategory::withCount(['articles' => function ($q) { $q->active()->forAccessLevel(); }]) ->orderBy('sort_order') ->get(); return response()->json([ 'featured' => ArticleCollectionResource::collection($featured), 'latest_blog' => ArticleCollectionResource::collection($latestBlog), 'latest_notice' => ArticleCollectionResource::collection($latestNotice), 'latest_document' => ArticleCollectionResource::collection($latestDocument), 'latest_related_news' => ArticleCollectionResource::collection($latestRelatedNews), 'about' => $aboutPage ? new PageResource($aboutPage) : null, 'categories' => CategoryResource::collection($categories), ]); } }