feat(controllers): optimize caching and view data passing

- Refactored the ChampionController, ChampionSkinController, HomeController, SaleController, SummonerEmoteController, and SummonerIconController to use arrow functions for cache callbacks.
- Updated the view data passing in the ChampionController, ChampionSkinController, HomeController, PostsController, SaleController, SummonerEmoteController, and SummonerIconController to use associative arrays instead of compact().
- Removed unused imports from web.php.
This commit is contained in:
Rico van Zelst
2024-01-06 00:15:19 +01:00
parent 3717d3836e
commit 85e3c4ff2e
8 changed files with 43 additions and 87 deletions

View File

@@ -9,15 +9,11 @@ class HomeController extends Controller
{
public function index()
{
$upcomingSkins = Cache::remember('upcomingSkins_home', 60 * 4, function () {
return ChampionSkin::where('availability', 'Upcoming')
->orderBy('release_date', 'desc')->get();
});
$upcomingSkins = Cache::remember('upcomingSkins_home', 60 * 4, static fn() => ChampionSkin::where('availability', 'Upcoming')
->orderBy('release_date', 'desc')->get());
$latestSkins = Cache::remember('latestSkins_home', 60 * 4, function () {
return ChampionSkin::where('availability', 'Available')
->orderBy('release_date', 'desc')->take(9)->get();
});
$latestSkins = Cache::remember('latestSkins_home', 60 * 4, static fn() => ChampionSkin::where('availability', 'Available')
->orderBy('release_date', 'desc')->take(9)->get());
return view('home', [
'latestSkins' => $latestSkins,