laravel seeder code example

Example 1: laravel migration seed fresh

php artisan migrate:fresh --seed

Example 2: laravel run seed

#All of them
php artisan db:seed
#One class
php artisan db:seed --class=UserSeeder

Example 3: how to run specific seeder in laravel

php artisan db:seed --class=UserSeeder

Example 4: laravel updateOrCreate

// If there's a flight from Oakland to San Diego, set the price to $99.
// If no matching model exists, create one.
$flight = App\Flight::updateOrCreate(
    ['departure' => 'Oakland', 'destination' => 'San Diego'],
    ['price' => 99, 'discounted' => 1]
);

Example 5: laravel make seeder

php artisan make:seeder NameOfTheSeeder

Example 6: make seeder laravel

php artisan make:seeder UserSeeder