withCount("danmakus")->orderByDesc("created_at")->paginate(10); return view("danmaku.index", [ "video_list" => $video_list, ]); } public function specific_search(Request $request, string $bvid) { $video = Videos::query()->withCount("danmakus")->where("bvid", "=", $bvid)->firstOrFail(); $keyword = $request->get("keyword", ""); $query = VideoDanmakus::query()->where("video_bvid", "=", $bvid); if ($keyword) { $keyword_split = explode(" ", $keyword); foreach ($keyword_split as $_keyword) { if (mb_strlen(trim($_keyword)) > 0) { $query->where(function ($_query) use ($_keyword) { $_query->where("content", "like", "%{$_keyword}%", "or")->where("from", "like", "%${_keyword}%", "or"); }); } } } $danmakus = $query->orderBy("created_at", "asc")->paginate(20); return view("danmaku.search_index", [ "keyword" => $keyword, "video" => $video, "danmakus" => $danmakus, ]); } }