From a901444fd974fbec41d83db3df6e8650446a43cd Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Wed, 21 Oct 2020 10:12:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E8=AF=A6=E6=83=85=20?= =?UTF-8?q?=E8=BF=94=E5=9B=9Ebanner=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Model/v3/Goods.php | 5 +++++ app/Service/v3/Implementations/GoodsService.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Model/v3/Goods.php b/app/Model/v3/Goods.php index 13e4411..5e07991 100644 --- a/app/Model/v3/Goods.php +++ b/app/Model/v3/Goods.php @@ -173,4 +173,9 @@ class Goods extends Model { $this->attributes['spec'] = json_encode(json_decode($value, true)); } + + public function banner() + { + return $this->hasMany(GoodsBanner::class, 'goods_id','id'); + } } \ No newline at end of file diff --git a/app/Service/v3/Implementations/GoodsService.php b/app/Service/v3/Implementations/GoodsService.php index 25bf28c..8105130 100644 --- a/app/Service/v3/Implementations/GoodsService.php +++ b/app/Service/v3/Implementations/GoodsService.php @@ -187,7 +187,7 @@ class GoodsService implements GoodsServiceInterface public function info($goodsId) { - $res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->first(); + $res = Goods::query()->withoutGlobalScope('normal')->where('id',$goodsId)->with('banner')->first(); return $res; }