Browse Source

首页banners

master
weigang 6 years ago
parent
commit
de70f1430a
  1. 6
      app/Controller/v3/GoodsRecommendController.php
  2. 12
      app/Model/v3/Goods.php
  3. 5
      app/Service/v3/Implementations/BannerService.php

6
app/Controller/v3/GoodsRecommendController.php

@ -207,6 +207,12 @@ class GoodsRecommendController extends BaseController
]
];
$goods = Goods::query()
->with(['store'])
->forPage($this->request->input('page', 1), $this->request->input('pagesize', 15))
->get()->toArray();
return $this->success(['tab_data' => $goods]);
return $this->success([
'tab_data' => $tabsData[$this->request->post('tab', 'applet_index_recommend')]
]);

12
app/Model/v3/Goods.php

@ -51,6 +51,8 @@ class Goods extends Model
protected $appends = [
'month_sales',
'cart_num',
'is_effective',
'noneffective_note',
];
protected function boot(): void
@ -87,6 +89,16 @@ class Goods extends Model
return (integer)$this->shopCartService->check($this->id);
}
public function getIsEffectiveAttribute()
{
return 1;
}
public function getNoneffectiveNoteAttribute()
{
return '';
}
public function store()
{
return $this->belongsTo(Store::class, 'store_id', 'id');

5
app/Service/v3/Implementations/BannerService.php

@ -9,6 +9,9 @@ class BannerService implements BannerServiceInterface
{
public function all($type, $marketId)
{
return Banner::query()->where(['type' => $type, 'market_id' => $marketId])->get()->toArray();
return Banner::query()
->where(['type' => $type])
->whereIn('market_id', [0,$marketId])
->get()->toArray();
}
}
Loading…
Cancel
Save