mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
fix: optimize queries
This commit is contained in:
@@ -9,16 +9,17 @@ class HomeController extends Controller
|
|||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$skins = Cache::remember('skins', 60 * 4, function () {
|
$upcomingSkins = Cache::remember('upcomingSkins_home', 60 * 4, function () {
|
||||||
return ChampionSkin::orderBy('release_date', 'desc')->get();
|
return ChampionSkin::where('availability', 'Upcoming')->orderBy('release_date', 'desc')->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
$upcomingSkins = Cache::remember('upcomingSkins', 60 * 4, function () use ($skins) {
|
$latestSkins = Cache::remember('latestSkins_home', 60 * 4, function () {
|
||||||
return $skins->where('availability', 'Upcoming');
|
return ChampionSkin::where('availability', 'Available')->orderBy('release_date', 'desc')->take(9)->get();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
return view('home', [
|
return view('home', [
|
||||||
'skins' => $skins,
|
'latestSkins' => $latestSkins,
|
||||||
'upcomingSkins' => $upcomingSkins,
|
'upcomingSkins' => $upcomingSkins,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class recent_skins extends Component
|
|||||||
/**
|
/**
|
||||||
* Create a new component instance.
|
* Create a new component instance.
|
||||||
*/
|
*/
|
||||||
public function __construct(public array $skins)
|
public function __construct(public array $latestSkins)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,14 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-1 gap-4 mt-8 md:grid-cols-3 lg:grid-cols-3 xl:grid-cols-3">
|
<div class="grid grid-cols-1 gap-4 mt-8 md:grid-cols-3 lg:grid-cols-3 xl:grid-cols-3">
|
||||||
@foreach ($skins as $skin)
|
@foreach ($latestSkins as $skin)
|
||||||
@if ($loop->index < 9)
|
@if ($loop->index < 9)
|
||||||
<div
|
<div
|
||||||
class="p-8 transition border shadow-xl border-stone-800 rounded-xl hover:border-orange-500/10 hover:shadow-orange-500/10">
|
class="p-8 transition border shadow-xl border-stone-800 rounded-xl hover:border-orange-500/10 hover:shadow-orange-500/10">
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<div class="flex flex-col items-center justify-center">
|
<div class="flex flex-col items-center justify-center">
|
||||||
<img loading="lazy" class="border-2 border-orange-400/40 rounded-xl"
|
<img loading="lazy" class="border-2 border-orange-400/40 rounded-xl"
|
||||||
src="{{ $skin->getSkinImageAttribute() }}" alt="{{ $skin->skin_name }} Splash Art">
|
src="{{ $skin->getSkinImageAttribute() }}" alt="{{ $skin->skin_name }} Splash Art">
|
||||||
<div class="flex flex-col items-center justify-center">
|
<div class="flex flex-col items-center justify-center">
|
||||||
<h2 class="mt-4 text-xl font-bold text-white">{{ $skin->skin_name }}</h2>
|
<h2 class="mt-4 text-xl font-bold text-white">{{ $skin->skin_name }}</h2>
|
||||||
<h3 class=" text-stone-200">Released
|
<h3 class=" text-stone-200">Released
|
||||||
|
|||||||
@@ -28,12 +28,12 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="antialiased bg-stone-800 dark">
|
<body class="antialiased bg-stone-800 dark">
|
||||||
<x-navbar/>
|
<x-navbar />
|
||||||
<x-home.features/>
|
<x-home.features />
|
||||||
@if($upcomingSkins != [])
|
@if ($upcomingSkins != [])
|
||||||
<x-home.upcoming_skins :upcomingSkins="$upcomingSkins"/>
|
<x-home.upcoming_skins :upcomingSkins="$upcomingSkins" />
|
||||||
@endif
|
@endif
|
||||||
<x-home.recent_skins :skins="$skins"/>
|
<x-home.recent_skins :latestSkins="$latestSkins" />
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user