laravel run seeder

127

eloquent run seeder -

php artisan db:seed --class=UserSeeder

laravel run seeder -

php artisan migrate:fresh --seed

laravel create seeder -

CREATE SEEDER -> run php artisan command:

php artisan make:seeder UsersTableSeeder

Create seeder in laravel -

step-1- php artisan make:seeder yourSeedername
step-2- //add data in inside run function in your new created seeder. eg
        $Records = [
            ['id'=>1, 'name'=>'abc','email'=>'[email protected]'],
            ['id'=>2, 'name'=>'xyz','email'=>'[email protected]']
        ];
        YourModel::insert($Records);
        //don't forget to use model in top of your seeder
step-3- //register seeder in run function inside Database/Seeders/DatabaseSeers.php as follows
        $this->call(yourseeder::class);
step-4- //Now run following command
        php artisan db:seed

Comments

Submit
0 Comments