[ 'title' => __('Featured Mods'), 'mods' => $this->fetchFeaturedMods(), 'link' => '/mods?featured=only', ], 'latest' => [ 'title' => __('Newest Mods'), 'mods' => $this->fetchLatestMods(), 'link' => '/mods', ], 'updated' => [ 'title' => __('Recently Updated Mods'), 'mods' => $this->fetchUpdatedMods(), 'link' => '/mods?order=updated', ], ]); } /** * Fetches the featured mods homepage listing. * * @return Collection */ private function fetchFeaturedMods(): Collection { return Mod::whereFeatured(true) ->with([ 'latestVersion', 'latestVersion.latestSptVersion', 'users:id,name', 'license:id,name,link', ]) ->inRandomOrder() ->limit(6) ->get(); } /** * Fetches the latest mods homepage listing. * * @return Collection */ private function fetchLatestMods(): Collection { return Mod::orderByDesc('created_at') ->with([ 'latestVersion', 'latestVersion.latestSptVersion', 'users:id,name', 'license:id,name,link', ]) ->limit(6) ->get(); } /** * Fetches the recently updated mods homepage listing. * * @return Collection */ private function fetchUpdatedMods(): Collection { return Mod::orderByDesc('updated_at') ->with([ 'latestUpdatedVersion', 'latestUpdatedVersion.latestSptVersion', 'users:id,name', 'license:id,name,link', ]) ->limit(6) ->get(); } }