Posts Learn Components new Snippets new Categories Tags About Device Beast sponsor

How to Delete All Rows or Truncate Model in Laravel

Learn how to easily delete all or truncate your table rows with Laravel model

Created on Jul 19, 2021


To delete all of your rows, you can make use of the "truncate()" method available on your model.

Laravel Truncate Code Example
So for example, if you want to delete all of your "Article" you can define it like below. Do note that the code below is defined within the "routes/web.php" file
Route::get('/delete-articles', function () {

So now when you visit "/delete-article", all of the articles will be deleted and emptied.

Delete All
One other way to delete all of the model records, you can make use of the "Article::query()->delete()". The advantage of using this method is that you get to listen to the Eloquent Event.

Snippets by

PostSrc poster


Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.


PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Other Code Snippets