Laravel delete multiple rows


Laravel delete multiple rows : You can delete multiple rows in laravel by passing array of ids which you want to delete. You can pass as much as ids you want to delete from the table. Here we are going to explain this with example.


Laravel delete multiple rows

Deleting multiple records by passing array of ids as below-

Mass Delete in Laravel Example 1

Laravel delete multiple rows

$ids = array(10, 20, 30);
DB::table('table_name')->whereIn('id', $ids)->delete(); 

Mass Delete in Laravel Example 2

Using model you can also perform mass deletion as below –

Laravel delete multiple rows

$deletedRows = Users::where('id', '>', 500)->delete();

Advertisements

Add Comment

📖 Read More