public function postCategories(Request $request)
 {
     if ($request->has('adds')) {
         $adds = $request->adds;
         for ($i = 0; $i < count($adds); $i++) {
             if ($adds[$i]['parent_id'] == 'null') {
                 Category::create(['title' => $adds[$i]['title']]);
             } else {
                 $parent = Category::find($adds[$i]['parent_id']);
                 $child = $parent->children()->create(['title' => $adds[$i]['title'], 'slug' => str_slug($adds[$i]['title'])]);
                 for ($j = 0; $j < count($adds); $j++) {
                     if ($adds[$j]['parent_id'] == $adds[$i]['id']) {
                         $adds[$j]['parent_id'] = $child->id;
                     }
                 }
             }
         }
     }
     if ($request->has('updates')) {
         $updates = $request->updates;
         for ($i = 0; $i < count($updates); $i++) {
             $category = Category::find($updates[$i]['id']);
             $category->update(['title' => $updates[$i]['title'], 'slug' => str_slug($updates[$i]['title'])]);
         }
     }
     if ($request->has('deletes')) {
         $deletes = $request->deletes;
         for ($i = 0; $i < count($deletes); $i++) {
             Category::destroy($deletes[$i]);
         }
     }
 }
 public function destroy($id)
 {
     Cache::forget('admin_category_categories_wfh');
     Cache::forget('wechat_index_categories_wfh');
     Category::destroy($id);
     return back();
 }
Example #3
0
 /**
  * delete data
  * @return json
  */
 public function delete()
 {
     $id = (int) $_POST['id'];
     $info = DB::select('select * from it_categories where parent_id = ?', [$id]);
     if ($info) {
         return response()->json(['status' => 100, 'message' => 'This category has child category cannot be deleted~~ ']);
     }
     $rs = Category::destroy($id);
     if ($rs) {
         return response()->json(['status' => 200, 'message' => 'Deleted Successfully~~']);
     } else {
         return response()->json(['status' => 400, 'message' => 'Delete Failure~~']);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy([$id]);
     return redirect('category');
 }
Example #5
0
 /**
  * Remove the specified category from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy($id);
     return Redirect::route('categories.index');
 }
Example #6
0
 public function delete($categoryID)
 {
     Category::destroy($categoryID);
     header("Location: " . base . "/Category");
 }
 public function destroy($id)
 {
     Cache::forget('wyshop_admin_category_categories');
     Category::destroy($id);
     return back()->with('info', '删除分类成功');
 }
Example #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if ($result = check_auth_to('FLGL_DELETE')) {
         return $result;
     }
     try {
         $count = Category::where('parent_id', '=', $id)->count();
         if ($count !== 0) {
             throw new \Exception("请先删除下级分类");
         }
         Category::destroy($id);
         return redirect()->action('Admin\\CategoryController@index')->with('operationstatus', 'sucess');
     } catch (\Exception $e) {
         return redirect()->back()->withErrors(['error' => '删除文章分类失败,请重试(' . $e->getMessage() . ')']);
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     Category::destroy($id);
     Session::flash('flash_message', 'Category deleted!');
     return redirect('backoffice/categories');
 }