Answers for "laravel delete record by id"

PHP
2

laravel 8 delete by id

//For a User table, to delete ID 1:

  $user = User::find(1);

  $user->delete();

//OR
  
  User::where('id', 1)->delete();

//OR
  
  User::destroy(1);

//OR
  
  User::destroy([1, 2, 3]);  //Delete id 1, 2 and 3
Posted by: Guest on July-01-2021

Browse Popular Code Answers by Language