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
Export Buttons In Datatable
Export Buttons In Datatable

In this tutorial i will show you How To Add Export Buttons In Datatable, If you want to export DataTable data...

Read More

Sep-02-2020

Laravel 8 One To Many Polymorphic Relationship
Laravel 8 One To Many Polymorp...

In this tutorial we will learn about laravel 8 one to many polymorphic relationship. A one-to-many polymorphic rela...

Read More

Nov-19-2021

How to Upgrade from Angular 16 to Angular 17
How to Upgrade from Angular 16...

Hey everyone! If you're a developer working with Angular, you know how exciting it is when a new version is released...

Read More

Mar-18-2024

How To Fix MySQL Shutdown Unexpectedly In XAMPP
How To Fix MySQL Shutdown Unex...

In this article, we will see how to fix "Error: MySQL shutdown unexpectedly" in XAMPP. When I open XAMPP...

Read More

Sep-22-2022