#All of them
php artisan db:seed
#One class
php artisan db:seed --class=UserSeeder
php artisan db:seed --class=UserSeeder
php artisan make:seeder NameOfTheSeeder
php artisan migrate:fresh --seed
CREATE SEEDER -> run php artisan command:
php artisan make:seeder UsersTableSeeder
php artisan make:seeder UsersTableSeeder
#To create a seeder
php artisan make:seeder CategorySeeder
let's see simple example:
you can use following command to all seeders in laravel application:
***************************
php artisan db:seed
***************************
you have to register all seeder in DatabaseSeeder.php file and that will run all seeders at a time, register as like bellow:
database/seeders/DatabaseSeeder.php
<?php
namespace DatabaseSeeders;
use IlluminateDatabaseSeeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call([
UserSeeder::class
AdminSeeder::class
]);
}
}
php artisan db:seed
php artisan db:seed --class=UserSeeder
make DatabaseSeerder class and call function with seeder Array
<?php
namespace DatabaseSeeders;
use IlluminateDatabaseSeeder;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
$this->call([
UserSeeder::class
AdminSeeder::class
]);
}
}
$ php artisan db:seed
DB::table('translations')->where('field', 'page_desc')->update(['field' => 'meta_desc']);
use AppModelsUser;
/**
* Run the database seeders.
*
* @return void
*/
public function run()
{
User::factory()
->count(50)
->hasPosts(1)
->create();
}