Improve Your Database Seeding

April 14th, 2023 · LinkedIn

Managing your Laravel database seeders efficiently is crucial for a smooth development process. One helpful tool you can use is the insertOrIgnore method. It allows you to insert data into a database table without worrying about duplicates, saving you time and effort.

use Illuminate\Support\Facades\DB;
class UserSeeder extends Seeder
public function run()
['name' => 'John Smith', 'email' => '[email protected]'],
['name' => 'Jane Doe', 'email' => '[email protected]'],
['name' => 'Bob Smith', 'email' => '[email protected]'],