干草..我的控制器上有功能删除..在客户端,当我删除catagories是工作..但是,当我检查哦phpmyadmin。类别仍未删除.. 这是我的categoriesController for delete ..
.........
public function destroy(Request $request,$id)
{
try {
DB::beginTransaction();
$category = Category::find($id);
$category->delete();
$request->session()->flash('alert-success','Data successfully deleted');
DB::commit();
return redirect(route('categories.index'));
}
catch (Exception $e) {
return Redirect::back()->with('error_message', $e->getMessage())->withInput();
}
}
请帮助..谢谢
答案 0 :(得分:0)
您应该尝试使用以下代码:
//For delete category
DB::table('category')->where('id',$id)->delete();
或强>
$category = Category::find($id);
$category->forceDelete();
答案 1 :(得分:0)
尝试这样做:
public function destroy($id)
{
$category = Category::destroy($id);
}