mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10: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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user