From 9cd2775be3185889976e3c42b9e9d851e9b0ac91 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sun, 10 Mar 2024 22:07:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AE=E6=92=AD=E5=9B=BE=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/model/Banner.php | 5 +++++ app/store/model/Banner.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/common/model/Banner.php b/app/common/model/Banner.php index 09691b74..0e1bd7f3 100644 --- a/app/common/model/Banner.php +++ b/app/common/model/Banner.php @@ -42,5 +42,10 @@ class Banner extends BaseModel ->bind(['image_url' => 'preview_url']); } + public function activeInfo(): HasOne + { + return $this->hasOne('ActiveMain', 'id', 'redirect_url'); + } + } diff --git a/app/store/model/Banner.php b/app/store/model/Banner.php index f95b9e4c..c3c885a3 100644 --- a/app/store/model/Banner.php +++ b/app/store/model/Banner.php @@ -28,7 +28,7 @@ class Banner extends BannerModel */ public function getList(): \think\Paginator { - $data = $this->order(['sort' => 'asc', 'create_time' => 'desc'])->paginate(); + $data = $this->with(['activeInfo'])->order(['sort' => 'asc', 'create_time' => 'desc'])->paginate(); return self::preload($data, ['image']); }