I'm currently working with models, migrations, seeds and fakers (factory) for testing the database.
So far, I've got to insert 1 admin, whose code I'll introduce:
DB::table('users')->insert([
'id'=>'1',
'name' => 'admin',
'email' => '[email protected]',
'password' => bcrypt('admin'),
'remember_token' => str_random(10),
]);
}}
My problem is that when I do the command php artisan db:seed
the second time it gives me an error that the users id already has a value of 1 and it is not possible to insert more.
I know that it is possible to check in User models whether an id already exists or not.
What I need is even that in the models of the User verify that there is already 1 admin if it exists it does not insert user but inserts the rest of the migrations.
I leave here the properties of the User model
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];