Delete all rows in the table using Eloquent

For deleting all rows in the table using eloquent the method is:

 MyModel::truncate();

This method can be used for Laravel 4 and 5 versions.

truncate() resets the AUTO_INCREMENT counter. You cannot do truncate if any foreign key constraints are present and truncate will not trigger delete events.

If you want to truncate a child table and parent table with foreign key reference, you can use the getQuery->delete method.

Model::getQuery()->delete();

For Laravel 5.6 use :

\App\Model::query()->delete();

If you disable the foreign key constraints Model::trunctate() can be used.

DB::statement("SET foreign_key_checks=0");

Model::truncate();

DB::statement("SET foreign_key_checks=1");