33 lines
861 B
PHP
33 lines
861 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Game;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class HomeController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$topRated = Cache::remember('home.top_rated', 300, fn() =>
|
|
Game::published()
|
|
->where('rating_count', '>=', 1)
|
|
->orderByDesc('rating_avg')
|
|
->orderByDesc('rating_count')
|
|
->limit(12)
|
|
->get()
|
|
);
|
|
|
|
$newReleases = Cache::remember('home.new_releases', 300, fn() =>
|
|
Game::published()
|
|
->whereNotNull('release_date')
|
|
->where('release_date', '<=', now())
|
|
->orderByDesc('release_date')
|
|
->limit(8)
|
|
->get()
|
|
);
|
|
|
|
return view('home', compact('topRated', 'newReleases'));
|
|
}
|
|
}
|