Laravel Redirect To Another URL / Web Page - HTTP Laravel Redirects

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.

  jQuery get value of select onChange Example

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

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\User;
use App\Http\Controllers\Controller;
use DB;
use Redirect;
use View;
use File;
class productDeleteController extends Controller
{
	public function multipleproductsdelete(Request $request)
	{
		$p_ids = $request->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.

  Laravel 6 Eloquent ORM Delete 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.