mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
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:
@@ -8,17 +8,15 @@ class SaleController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$sales = Cache::remember('sales_data', 60 * 60 * 8, function () {
|
||||
$sales = Cache::remember('sales_data', 60 * 60 * 8, static function () {
|
||||
$shopData = json_decode(
|
||||
file_get_contents('https://api.shop.riotgames.com/v3/collections/'),
|
||||
true
|
||||
);
|
||||
$salesData = array_filter($shopData, function ($collection) {
|
||||
return $collection['path'] === '/event/sales';
|
||||
});
|
||||
$salesData = array_filter($shopData, static fn($collection) => $collection['path'] === '/event/sales');
|
||||
return reset($salesData)['dynamicCollection']['discountedProductsByProductType'] ?? [];
|
||||
});
|
||||
|
||||
return view('sales.index', compact('sales'));
|
||||
return view('sales.index', ['sales' => $sales]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user