riyenperdana

Destroy

May 17th, 2021 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. public function destroy($id)
  2.     {
  3.         $category = Category::findOrFail($id);
  4.         $image = Storage::disk('local')->delete('public/categories/'.$category->image);
  5.         $category->delete();
  6.         if($category){
  7.             return response()->json(['status' => 'success']);
  8.         } else {
  9.             return response()->json(['status' => 'error']);
  10.         }
  11.     }
Add Comment
Please, Sign In to add comment