예제 #1
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;
 }
예제 #2
0
 public function update(Request $request, $id)
 {
     $params = $request->all();
     $themes = Themes::find($id);
     if ($themes != null) {
         if ($request->hasFile('coverImage')) {
             $file = $request->file('coverImage');
             $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension();
             $file->move(base_path() . '/public/upload', $fileName);
             $params['cover'] = '/upload/' . $fileName;
         }
         unset($params['coverImage']);
         if ($request->hasFile('headImage')) {
             $file = $request->file('headImage');
             $fileName = md5(uniqid()) . '.' . $file->getClientOriginalExtension();
             $file->move(base_path() . '/public/upload', $fileName);
             $params['head_image'] = '/upload/' . $fileName;
         }
         unset($params['headImage']);
         unset($params['_token']);
         $params['category_id'] = $params['category'];
         unset($params['category']);
         if ($params['type'] == 1) {
             $params['themes_description'] = $params['description'];
             unset($params['description']);
         }
         $chooseGoods = $params['chooseGoods'];
         unset($params['chooseGoods']);
         foreach ($params as $n => $p) {
             $themes->{$n} = $p;
         }
         $themes->save();
         ThemeGoods::where('theme_id', $themes->id)->delete();
         $len = strlen($chooseGoods);
         if ($len > 0) {
             $chooseGoods = substr($chooseGoods, 0, $len - 1);
             $chooseGoods = explode(',', $chooseGoods);
             foreach ($chooseGoods as $i) {
                 $themeGoods = new ThemeGoods();
                 $themeGoods->goods_id = $i;
                 $themeGoods->theme_id = $themes->id;
                 $themeGoods->save();
             }
         }
     }
     return redirect()->action('Admin\\ThemesController@show');
 }