From 2c172e89a9a2f75f51f80f6755d5eefc08e931cd Mon Sep 17 00:00:00 2001 From: jsasg <735273025@qq.com> Date: Wed, 16 Apr 2025 10:59:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E9=99=84?= =?UTF-8?q?=E4=BB=B6=E5=8F=8A=E8=A7=86=E9=A2=91=E5=88=86=E7=B1=BB=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/index/controller/Attachment.php | 8 ++++++++ app/index/model/VideoModel.php | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/app/index/controller/Attachment.php b/app/index/controller/Attachment.php index 91309b0a..468bb3c8 100644 --- a/app/index/controller/Attachment.php +++ b/app/index/controller/Attachment.php @@ -53,6 +53,9 @@ class Attachment extends Common ->paginate([ 'list_rows' => $param['size'], 'page' => $param['page'], + 'query' => [ + 'id' => $param['id']??null + ] ]); View::assign('attachements', $attachements); View::assign('page', $attachements->render()); @@ -66,6 +69,7 @@ class Attachment extends Common public function video() { $param = request()->param([ + 'id', 'page/d' => 1, 'size/d' => 12 ]); @@ -103,10 +107,14 @@ class Attachment extends Common 'link' ]) ->language($this->lang_id) + ->category($param['id']??null) ->order(['sort' => 'asc', 'id' => 'desc']) ->paginate([ 'list_rows' => $param['size'], 'page' => $param['page'], + 'query' => [ + 'id' => $param['id']??null + ] ]); View::assign('videos', $videos); View::assign('page', $videos->render()); diff --git a/app/index/model/VideoModel.php b/app/index/model/VideoModel.php index dce62a1f..3ebbb1a1 100644 --- a/app/index/model/VideoModel.php +++ b/app/index/model/VideoModel.php @@ -29,4 +29,13 @@ class VideoModel extends VideoBaseModel { $query->where('recommend', '=', (int)$recommend); } + + // 所属分类范围查询 + public function scopeCategory($query, $category) + { + if (is_null($category)) { + return; + } + $query->where('category_id', '=', $category); + } }