published()->with('category'); if ($request->filled('q')) { $builder->whereFullText(['title', 'excerpt', 'body'], (string) $request->string('q')); } if ($request->filled('category')) { $builder->whereHas('category', function ($query) use ($request): void { $query->where('slug', (string) $request->string('category')); }); } return view('public.news.index', [ 'items' => $builder->latest('published_at')->paginate(15)->withQueryString(), 'categories' => Category::query()->where('type', 'news')->where('is_active', true)->orderBy('name')->get(), 'filters' => $request->only(['q', 'category']), 'sidebarModels' => AiModel::published()->orderByDesc('total_score')->limit(6)->get(), 'sidebarGuides' => Guide::published()->latest('published_at')->limit(6)->get(), ]); } public function show(string $slug): View { /** @var Article $article */ $article = Article::query() ->published() ->with(['category', 'source']) ->where('slug', $slug) ->firstOrFail(); return view('public.news.show', [ 'item' => $article, 'bodyHtml' => $this->markdownRenderer->render($article->body), 'showRiskNotice' => $this->containsRiskKeyword($article->title.' '.$article->body), ]); } private function containsRiskKeyword(string $text): bool { return str_contains($text, '医疗') || str_contains($text, '法律') || str_contains($text, '投资'); } }