init
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
jiangdong.cheng
2026-02-11 17:28:36 +08:00
parent dcb82557c7
commit aa16c9f8c2
162 changed files with 22333 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Site;
use App\Http\Controllers\Controller;
use App\Models\AiModel;
use App\Models\Article;
use App\Models\Category;
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_v2', now()->addMinutes(10), function (): array {
$latestTools = Tool::published()->latest('published_at')->limit(10)->get();
$latestModels = AiModel::published()->orderByDesc('total_score')->limit(10)->get();
$latestArticles = Article::published()->latest('published_at')->limit(10)->get();
$latestGuides = Guide::published()->latest('published_at')->limit(10)->get();
return [
'stats' => [
'tools' => Tool::published()->count(),
'models' => AiModel::published()->count(),
'articles' => Article::published()->count(),
'guides' => Guide::published()->count(),
],
'featuredTools' => $latestTools->take(4),
'featuredModels' => $latestModels->take(4),
'toolList' => $latestTools->take(8),
'modelList' => $latestModels->take(8),
'articleList' => $latestArticles->take(8),
'guideList' => $latestGuides->take(8),
'hotKeywords' => [
'AI导航', '工作流自动化', '多模态模型', 'AIGC 设计', 'AI 编程助手', '提示词模板', '行业快讯', '模型评测',
],
'moduleCategories' => [
'tools' => Category::query()->where('type', 'tool')->where('is_active', true)->orderBy('name')->limit(8)->get(),
'models' => Category::query()->where('type', 'model')->where('is_active', true)->orderBy('name')->limit(8)->get(),
'news' => Category::query()->where('type', 'news')->where('is_active', true)->orderBy('name')->limit(8)->get(),
'guides' => Category::query()->where('type', 'guide')->where('is_active', true)->orderBy('name')->limit(8)->get(),
],
];
});
return view('public.home', $payload);
}
}