Seeder
Fills the DB automatically with the registered previously loaded.
Create a Seeder
Use the format <Table_Name>TableSeeder as standart
php artisan make:seeder UsersTableSeeder
The new class will appear in database/seeders
Query Builder
In the method Run, add the registeres to be inserted
DB::table('users')->insert([
'name' => str_random(10),
'email' => str_random(10).'@gmail.com',
'password' => bcrypt('secret'),
]);
Run Seeder
Only execute the DatabaseSeeder
php artisan db:seed
You can add your seeder as:
// $this->call(<yourclass>::class);
php artisan db:seed --class=UserTableSeeder
php artisan migrate:refresh --seed
Comentarios
Publicar un comentario