Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 1 year ago.
0

If you're on MySQL (and you probably are) try to turn off foreign key checks using this statement before you truncate data in tables with foreign key constraints.

<?php
DB::statement("SET foreign_key_checks = 0");

A reasonable place to put this would be app/database/seeds/DatabaseSeeder.php at the beginning of run() method.

Last updated 1 year ago.
0

I use DB::table('lessons')->delete();

Last updated 1 year ago.
0

@Oliver Thanks for different solution, I haven't tried but in my case setting foreign key check more reasonable.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

metude metude Joined 13 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.