From 37afb2264104dccc3aa70b704fffe973e1a83113 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Tue, 1 Jul 2025 11:02:20 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A8=BF=E4=BB=B6=E6=9F=A5=E8=AF=A2=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/DanmakuQueryController.php | 19 +++++++++++++++---- resources/views/danmaku/index.blade.php | 5 +++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/DanmakuQueryController.php b/app/Http/Controllers/DanmakuQueryController.php index 4beb846..01c4562 100644 --- a/app/Http/Controllers/DanmakuQueryController.php +++ b/app/Http/Controllers/DanmakuQueryController.php @@ -10,13 +10,24 @@ use Illuminate\Routing\Controller as BaseController; class DanmakuQueryController extends BaseController { - public function index() + public function index(Request $request) { - $video_list = Videos::query() + $keyword = $request->get("keyword", ""); + $query = Videos::query() ->withCount("danmakus", "bilibili_danmakus", "ixigua_danmakus", "douyin_danmakus", "programs") - ->orderByDesc("created_at") - ->paginate(10)->withQueryString(); + ->orderByDesc("created_at"); + if ($keyword) { + $keyword_split = explode(" ", $keyword); + foreach ($keyword_split as $_keyword) { + $_keyword = trim($_keyword); + if (mb_strlen($_keyword) > 0) { + $query->where("title", "like", "%{$_keyword}%"); + } + } + } + $video_list = $query->paginate(10)->withQueryString(); return view("danmaku.index", [ + "keyword" => $keyword, "video_list" => $video_list, ]); } diff --git a/resources/views/danmaku/index.blade.php b/resources/views/danmaku/index.blade.php index bc3e428..a78c4d1 100644 --- a/resources/views/danmaku/index.blade.php +++ b/resources/views/danmaku/index.blade.php @@ -7,6 +7,11 @@
@include("common.header") + @foreach($video_list as $video)