Beispiel #1
0
 public function getDelete($id)
 {
     $parent = Cate::where('parent_id', $id)->count();
     if ($parent == 0) {
         $cate = Cate::find($id);
         $cate->delete($id);
         return redirect()->route('admin.cates.list')->with(['flash_level' => 'success', 'flash_message' => 'Success !! Complate Delete Category']);
     } else {
         return redirect()->route('admin.cates.list')->with(['flash_level' => 'danger', 'flash_message' => 'Error !! You can\'t Delete this Category']);
     }
 }
Beispiel #2
0
 public function getDelete($id)
 {
     $parent = Cate::where('parent_id', $id)->count();
     if ($parent == 0) {
         $cate = Cate::find($id);
         $cate->delete();
         return redirect()->route('admin.cate.list')->with(['flash_level' => 'success', 'flash_message' => 'Success ! Complete delete category']);
     } else {
         echo "<script type='text/javascript'>\n                alert('You Can Not Delete This Category');\n                window.location = '";
         echo route('admin.cate.list');
         echo "';\n            </script>";
     }
 }
 public function DiscountGetDelete($id)
 {
     Cate::where("discount_id", $id)->update(["discount_id" => 0]);
     $discount = Discount::find($id);
     $discount->delete();
     return redirect()->route("admin.discount.list");
 }
Beispiel #4
0
 public function update(Requests\CreateArticleRequest $request, $id)
 {
     $article = Article::findOrFail($id);
     $oldCateId = $article->cate_id;
     $article->update($request->all());
     $oldTags = Tag::where(['user_id' => \Auth::user()->id, 'article_id' => $id])->delete();
     $newTags = $request->get('tags');
     if ($newTags && $newTags != "多个标签以,分隔") {
         $newTags = str_replace(',', ',', $newTags);
         //中文状态逗号,替换成英文逗号
         $newTags = trim($newTags, ',');
         $arr = explode(',', $newTags);
         //拆分标签入库
         foreach ($arr as $k => $v) {
             Tag::create(array('tag' => $v, 'user_id' => \Auth::user()->id, 'article_id' => $article->id));
         }
     }
     //更新分类数据
     if ($oldCateId != $request->get('cate_id')) {
         //有分类的文章才执行原有分类自增
         if ($article->cate_id > 0) {
             Cate::where('id', $oldCateId)->decrement('count');
             Cate::where('id', $request->get('cate_id'))->increment('count');
         } else {
             //
         }
     }
     return redirect('/articles');
 }