laravel delete multiple rows code example

Example 1: how delete multiple row from relation in laravel

App\Post;
$post = Post::find($id);
Comment::where('post_id',$post)->delete();

Example 2: How to Delete Multiple Records using Checkbox in Laravel

public function deleteAll(Request $request)
{
  $ids = $request->ids;
  DB::table("products")->whereIn('id',explode(",",$ids))->delete();
  return response()->json(['success'=>"Products Deleted successfully."]);
}
//@sujay

Example 3: laravel delete multiple rows

$org->products()->whereIn('id', $ids)->delete()

Tags:

Misc Example