How to Run Specific Seeder in Laravel 8

Websolutionstuff | Jan-19-2022 | Categories : Laravel

In this example, we will learn how to run a specific seeder in laravel 8. If you want to run only one seeder in laravel then you can run a specific seeder, here I will show you how to run a specific seeder in laravel 8 or how to run a seeder in laravel.

Using db:seed Artisan command you can seed your database but --class option to specify a specific seeder class to run seeder individually:

 

Run Specific Seeder In Laravel

I have added some steps below to run a specific seeder in laravel 8:

php artisan db:seed --class=AdminSeeder

 

Now, you will find the seeder file in this file location database/seeders/AdminSeeder.php.

<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use App\Models\Admin;


class AdminSeeder extends Seeder

{
/**
* Run the database seeds.
*
* @return void
*/

public function run()
{

Admin::create([

"name" => "websolutionstuff",
"email" => "[email protected]",
"password" => bcrypt("123456789")

]);

}

}

 

Using the below command you can run all seeder in laravel.

php artisan db:seed

 

Using the below command you can run migrate with seeder in laravel.

php artisan migrate:fresh --seed

 

Using the below command you can run force seeder for production in laravel.

php artisan db:seed --force

//To run spicific seeder

php artisan db:seed --class=AdminSeeder --force

 


You might also like :

Recommended Post
Featured Post
Laravel 8 Datatables Filter with Dropdown
Laravel 8 Datatables Filter wi...

In this example we will see laravel 8 datatables filter with dropdown, Here we will add datatables custom...

Read More

Jun-16-2021

How To Get Selected Checkbox List Value In Jquery
How To Get Selected Checkbox L...

In this tutorial, I will explain you to how to get the selected checkbox value from a checkbox list in jquery, If y...

Read More

Jun-17-2020

How To Use OpenAI In Laravel 8/9
How To Use OpenAI In Laravel 8...

In this article, we will explore the integration of OpenAI into Laravel versions 8, 9, and 10. Our focus will be on unde...

Read More

Feb-06-2023

How to Validate Empty Input Field in jQuery
How to Validate Empty Input Fi...

In the dynamic world of web development, form validation is a crucial aspect of creating a user-friendly and error-free...

Read More

Sep-25-2023