In this article, you will learn How to Run a Specific Seeder or All Seeders in laravel.
By the end of the article, you will know both how to run the specific seeder and how to run all seeders in laravel.
Let’s get started!
Table of Contents
How to Run all Seeders in laravel?
Step 1: Assumption
Let’s assume that you have created
Step 2: Register Seeders
Register all seeders files which you have created in
database/seeders/DatabaseSeeder.php file in the run function. In our case we have two seeders
AdminSeeder which we are registering.
class DatabaseSeeder extends Seeder
* Seed the application's database.
* @return void
public function run()
Step 3: Run Seeder Command
Now you have run the following command in order to run all seeder in laravel application:
php artisan db:seed
How to Run Specific Seeder in laravel?
Make sure you have created the seeder already. In our case, lets say we want to run just
UserSeeder then we will run the following command:
php artisan db:seed --class=UserSeeder
Note: UserSeeder is the name of our seeder file and it should be replaced by your seeder file name.
Hope in the above article, you have learned how to run specific seeder and all seeders in laravel with the example. Let me know if you have any questions in the comments. See you soon in the next one!