37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Public;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Models\AiModel;
|
||
|
|
use App\Models\Article;
|
||
|
|
use App\Models\Guide;
|
||
|
|
use App\Models\Tool;
|
||
|
|
use Illuminate\Contracts\View\View;
|
||
|
|
use Illuminate\Support\Facades\Cache;
|
||
|
|
|
||
|
|
class HomeController extends Controller
|
||
|
|
{
|
||
|
|
public function __invoke(): View
|
||
|
|
{
|
||
|
|
$payload = Cache::remember('home_page_payload', now()->addMinutes(10), function (): array {
|
||
|
|
return [
|
||
|
|
'stats' => [
|
||
|
|
'tools' => Tool::published()->count(),
|
||
|
|
'models' => AiModel::published()->count(),
|
||
|
|
'articles' => Article::published()->count(),
|
||
|
|
'guides' => Guide::published()->count(),
|
||
|
|
],
|
||
|
|
'latestTools' => Tool::published()->latest('published_at')->limit(8)->get(),
|
||
|
|
'latestModels' => AiModel::published()->orderByDesc('total_score')->limit(8)->get(),
|
||
|
|
'latestArticles' => Article::published()->latest('published_at')->limit(6)->get(),
|
||
|
|
'latestGuides' => Guide::published()->latest('published_at')->limit(6)->get(),
|
||
|
|
];
|
||
|
|
});
|
||
|
|
|
||
|
|
return view('public.home', $payload);
|
||
|
|
}
|
||
|
|
}
|