Пример #1
0
 public function getGoodsAttribute()
 {
     //$goodsList=OrderGoods::with('goods')->where('order_id',$this->id)->get();
     $goodsList = BannerGoods::where('banner_id', $this->id)->get();
     if ($goodsList == null) {
         return null;
     }
     return $goodsList->toArray();
 }
Пример #2
0
 public function update(Request $request, $id)
 {
     $params = $request->all();
     $banner = Banner::find($id);
     if ($banner != null) {
         if ($banner->type == 4) {
             BannerGoods::where('banner_id', $banner->id)->delete();
         }
         $banner->title = $params['title'];
         $banner->order = $params['order'];
         $banner->banner_position = $params['banner_position'];
         $banner->type = $params['type'];
         if ($request->hasFile('coverImage')) {
             $file = $request->file('coverImage');
             $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension();
             $file->move(base_path() . '/public/upload', $fileName);
             $banner->path = '/upload/' . $fileName;
         }
         if ($banner->type == 2) {
             if ($request->hasFile('detailImage')) {
                 $file = $request->file('detailImage');
                 $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension();
                 $file->move(base_path() . '/public/upload', $fileName);
                 $banner->detail_image = '/upload/' . $fileName;
             }
             $banner->item_id = substr($params['item_id'], 0, strlen($params['item_id']) - 1);
             $banner->save();
         } elseif ($banner->type == 0 || $banner->type == 1) {
             $banner->item_id = substr($params['item_id'], 0, strlen($params['item_id']) - 1);
             $banner->save();
         } elseif ($banner->type == 4) {
             $banner->save();
             $items = substr($params['item_id'], 0, strlen($params['item_id']) - 1);
             $items = explode(',', $items);
             foreach ($items as $v) {
                 $bannerGoods = new BannerGoods();
                 $bannerGoods->banner_id = $banner->id;
                 $bannerGoods->goods_id = $v;
                 $bannerGoods->save();
             }
         }
     }
     return redirect()->action('Admin\\BannerController@show');
 }
Пример #3
0
 private function hasUse($id)
 {
     if (ThemeGoods::where('goods_id', $id)->count() > 0) {
         return -1;
     }
     if (BannerGoods::where('goods_id', $id)->count() > 0) {
         return -2;
     }
     if (ActivityClassificationGoods::where('goods_id', $id)->count() > 0) {
         return -3;
     }
     if (ConversionGoods::where('goods_id', $id)->count() > 0) {
         return -4;
     }
     if (FreePostGoods::where('goods_id', $id)->count() > 0) {
         return -5;
     }
     if (HomeButtonGoods::where('goods_id', $id)->count() > 0) {
         return -6;
     }
     return 1;
 }