In the previous tutorial, you have learned how to insert, retrieve/fetch, update data / records into a database table in laravel web application.
In this delete data into database table laravel tutorial. You will learn how to delete data into the database table in laravel web applications.
Laravel Delete Data In Database Example
- Create Routes
- Create Delete Method in Controller
- Start Development Server
Now, open your project in a text editor and go to routes/web.php file and update the following routes into your file:
Create Delete Method in Controller
Next step, you need to create one method in the controller for delete data from the database table.
The deleteRecord() method delete the data from the database table.
So update the below methods in your PostController.php:
class PostController extends Controller
public function deleteRecord(Request $request, $id)
$check = Post::where('id', $id)->delete();
return Redirect::to("list")->withSuccess('Great! data successfully deleted');
Start development server
You can use the following command artisan command to start the development server:
php artisan serve
The final step, go to your browser and type the below-given URL into your browser:
This tutorial idea has taken from the following urls: