/** * Delete a category. * * @param Category $category * @return mixed */ public function deleteCategory(Category $category) { $result = \DB::transaction(function () use($category) { return $category->delete(); }); return $result; }
/** * * @param Category $category * @return Response */ public function destroy(Category $category) { try { $category->delete(); return response([], Response::HTTP_NO_CONTENT); } catch (\Exception $e) { //Integrity constraint violation if ($e->getCode() === '23000') { $message = 'Category could not be deleted. It is in use.'; } else { $message = 'There was an error'; } return response(['error' => $message, 'status' => Response::HTTP_BAD_REQUEST], Response::HTTP_BAD_REQUEST); } }
/** * Remove the specified Category from storage. * * @param DeleteInventoryRequest $request * * @param Category $category * @return Response * @throws \Exception */ public function destroy(DeleteInventoryRequest $request, Category $category) { $this->data = $category->delete(); return $this->handleRedirect($request, route('backend.categories.index')); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy(Category $categories) { $categories->delete(); return redirect()->route('admin.categories.index'); }
/** * Destroy sent category * * @param Category $category * @return View */ public function destroy(Category $category) { // Delete category $category->delete(); return redirect(route('AdminCategoryIndex')); }