public function deleteCategory(Request $request)
    {
        $this->validate(
            $request,
            [
                'category_id' => 'required|integer|exists:categories',
            ]
        );

        $category = Category::find($request->input('category_id'));

        if ($category->items()->count()) {
            return redirect()->back()->withErrors(['category_id' => trans('mustard::admin.category_has_items')]);
        }

        $category->delete();

        return redirect()->back()->withStatus(trans('mustard::admin.category_deleted'));
    }
public function deleteCategory(Request $request)
    {
        $this->validate(
            $request,
            [
                'category_id' => 'required|integer|exists:categories',
            ]
        );

        $category = Category::find($request->input('category_id'));

        if ($category->items()->count()) {
            return redirect()->back()->withErrors(['category_id' => trans('mustard::admin.category_has_items')]);
        }

        $category->delete();

        return redirect()->back()->withStatus(trans('mustard::admin.category_deleted'));
    }
public function deleteCategory ( Request $ request ) { $ this -> validate ( $ request , [ 'category_id' => 'required|integer|exists:categories' , ] ) ; $ category = Category :: find ( $ request -> input ( 'category_id' ) ) ; if ( $ category -> items ( ) -> count ( ) ) { return redirect ( ) -> back ( ) -> withErrors ( [ 'category_id' => trans ( 'mustard::admin.category_has_items' ) ] ) ; } $ category -> delete ( ) ; return redirect ( ) -> back ( ) -> withStatus ( trans ( 'mustard::admin.category_deleted' ) ) ; }
Delete a category.

@return \Illuminate\Http\RedirectResponse
Delete a category .