Posted inTechnology / Laravel / Mysql / Mysqli / php / Programming

laravel 6 Delete Multiple Records Eloquent

Today, We want to share with you laravel 6 Delete Multiple Records Eloquent.In this post we will show you How to delete multiple rows with checkbox using ajax in PHP Laravel 6.2 with example, hear for laravel delete where in array we will give you demo and example for implement.In this post, we will learn about How to Delete Multiple Rows Using Checkbox in PHP & Laravel Using Eloquent & Javascript ? with an example.

laravel 6 Delete Multiple Records Eloquent

There are the Following The simple About multiple delete in php with checkbox Full Information With Example and source code.

As I will cover this Post with live Working example to develop Delete all rows in the table using Eloquent, so the multiple checkbox in laravel 6.2 is used for this example is following below.

delete row using ajax in laravel 6

routes/web.php

use App\Product;
use Illuminate\Http\Request;

Route::post('product-delete',function(Request $request) {
	$all_data = $request->except('_token');
	foreach($all_data as $id) {
		Product::where('id',$id)->delete();
	}
	return redirect()->back();
});

Delete row using ajax in laravel 6

app/Http/Controllers/productDeleteController.php

id;
		foreach ($p_ids as $product) {
			DB::table('products')->where('id', $product)->delete();
		}
		return redirect()->back()->with('message','Successfully Delete Your Multiple products.');
	}
}

Laravel 6.0 delete multiple rows

We can delete multiple rows in laravel 6 by passing simple array of products ids which you want to delete. We can pass as much as product ids you want to remove or delete from the MySQL Database table. Here we are going to step by step explain this with demo and example.

Mass Delete in Laravel 6.0 Example 1

$product_ids = array(50245, 50214, 50478);
DB::table('products')->whereIn('id', $product_ids)->delete(); 

Mass Delete in Laravel 6.0 Example 2

$deletedProducts = Product::where('id', '>', 500)->delete();
Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about delete data from multiple tables in laravel 6.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype