laravel 8 delete by id

Solutions on MaxInterview for laravel 8 delete by id by the best coders in the world

showing results for - "laravel 8 delete by id"
Moritz
20 Sep 2019
1//For a User table, to delete ID 1:
2
3  $user = User::find(1);
4
5  $user->delete();
6
7//OR
8  
9  User::where('id', 1)->delete();
10
11//OR
12  
13  User::destroy(1);
14
15//OR
16  
17  User::destroy([1, 2, 3]);  //Delete id 1, 2 and 3