mardi 2 avril 2019

laravel seeds unique column ignore duplicate entries

i have a Seeder in Laravel

public function run()
    {
        $user = App\Admin::create([

            'first_name'     => 'first',
            'last_name'    => 'last',
            'phone'    => '',
            'email'    => 'mail@gmail.com',
        ]);
    }

in this email is unique,

php artisan db:seed

when I run first time its entering records into the database, when I run again its showing duplicate entry.

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'mail@gmail.com' for key 'email'

do i have option to ignore that.?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire