Laravel is a very popular php framework. It provides the feature of seeder to seed the database with sample data for testing purposes or with some ready to use data.
In this tutorial, we will know how to run a specific seeder instead of all seeders at once. As a developer database seeders are very helpful to feed the sample data to the database and test the application smoothly. It eliminates the need of manual data for testing the laravel project.
If you are already familiar with laravel 9 database seeders then you might know that we create the seeder classes to run the seeder. So, to run a specific seeder we need to mention the class in the seeder command as given below:
php artisan db:seed php artisan db:seed --class=UserSeeder
Sometimes you might need to run cache
clear commands or composer dump-autoload
command, if your seeder class is discovered yet. In this case you might see the error.
“Target class [Database\Seeders\YourSeederClass] does not exist.”
There is another thing which is important to know. If you are refreshing the complete database with migrate:fresh
command and then running the specific seeder class, here you can do all of this with just a single command.
php artisan migrate:fresh --seed php artisan migrate:fresh --seed --seeder=UserSeeder
That’s it. How to run a specific seeder in laravel 9. Hope it will help you.
Today we are going to learn about managing multiple PHP versions on ubuntu with xampp.…
Let's understand about how to use coding to improve your website's SEO. In today’s computerized…
Let's understand the most important linux commands for web developers. Linux, as an open-source and…
Today we are going to discuss top 75+ Laravel interview questions asked by top MNCs.Laravel,…
Today we will discuss about the Mailtrap integration with laravel 10 .Sending and receiving emails…
Today we are going to integrate FCM (Firebase Cloud Messaging) push notifications with ionic application.Firebase…