mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 18:20:48 +01:00
feat: caching
This commit is contained in:
@@ -3,15 +3,23 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ChampionSkin;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
$skins = ChampionSkin::orderBy('release_date', 'desc')->get();
|
||||
$skins = Cache::remember('skins', 60 * 4, function () {
|
||||
return ChampionSkin::orderBy('release_date', 'desc')->get();
|
||||
});
|
||||
|
||||
$upcomingSkins = Cache::remember('upcomingSkins', 60 * 4, function () use ($skins) {
|
||||
return $skins->where('availability', 'Upcoming');
|
||||
});
|
||||
|
||||
return view('home', [
|
||||
'skins' => $skins,
|
||||
'upcomingSkins' => $upcomingSkins,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@ namespace App\View\Components\Home;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\View\Component;
|
||||
|
||||
class Upcoming_skins extends Component
|
||||
class upcoming_skins extends Component
|
||||
{
|
||||
public function __construct(public array $skins)
|
||||
public function __construct(public array $upcomingSkins)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Database\Seeders;
|
||||
// use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
@@ -18,6 +19,8 @@ class DatabaseSeeder extends Seeder
|
||||
$this->call(SkinChromaSeeder::class);
|
||||
$this->call(ChampionRolesSeeder::class);
|
||||
|
||||
Cache::flush();
|
||||
|
||||
Log::info('Seeding complete at ' . date('Y-m-d H:i:s'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
</p>
|
||||
</div>
|
||||
<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)
|
||||
@if($skin->availability == "Upcoming")
|
||||
@foreach ($upcomingSkins as $skin)
|
||||
<div
|
||||
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">
|
||||
@@ -32,7 +31,6 @@
|
||||
@else
|
||||
{{ $skin->rp_price }} RP
|
||||
@endif
|
||||
|
||||
</p>
|
||||
<p class="mt-1 text-sm italic text-stone-300">
|
||||
@if ($skin->loot_eligible)
|
||||
@@ -43,11 +41,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@endforeach
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
<body class="antialiased bg-stone-800 dark">
|
||||
<x-navbar/>
|
||||
<x-home.features/>
|
||||
<x-home.upcoming_skins :skins="$skins"/>
|
||||
@if($upcomingSkins != [])
|
||||
<x-home.upcoming_skins :upcomingSkins="$upcomingSkins"/>
|
||||
@endif
|
||||
<x-home.recent_skins :skins="$skins"/>
|
||||
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user