December 7, 2016 —John Koster
The make:seeder
command can be used to generate new seed classes. The command accepts a name
argument that will be used as the name of the newly generated file and class. Generated seeder classes are stored in the database/seeds/
directory by default.
This command will not overwrite any existing seeder classes that have the same name. An error stating Seeder already exists!
will be displayed instead.
The following example demonstrates how to call the make:seeder
command:
1# Generate a new database seeder class.2php artisan make:seed DrinksSeeder
A database/seeds/DrinksSeeder.php
file would be created with contents similar to the following:
1<?php 2 3use Illuminate\Database\Seeder; 4 5class DrinksSeeder extends Seeder 6{ 7 /** 8 * Run the database seeds. 9 *10 * @return void11 */12 public function run()13 {14 //15 }16}
The make:seeder
command is also capable of generated seeder classes within nested directories. Accomplish this by separating directory sections using the \
when supplying the seeder name. A nested directory will be created (seeder classes are not namespaced by default).
∎
The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.