php artisan make:seeder UsersTableSeeder
step-1- php artisan make:seeder yourSeedername
step-2- //add data in inside run function in your new created seeder. eg
$Records = [
['id'=>1, 'name'=>'abc','email'=>'abc@gmail.com'],
['id'=>2, 'name'=>'xyz','email'=>'xyz@gmail.com']
];
YourModel::insert($Records);
//don't forget to use model in top of your seeder
step-3- //register seeder in run function inside Database/Seeders/DatabaseSeers.php as follows
$this->call(yourseeder::class);
step-4- //Now run following command
php artisan db:seed
#To create a seeder
php artisan make:seeder CategorySeeder
use IlluminateSupportFacadesDB;
use IlluminateSupportFacadesHash;
...
...
DB::table('users')->insert([
'name' => 'John Doe',
'email' => 'john@doe.com',
'password' => Hash::make('password')
]);
$ php artisan make:seeder MoviesTableSeeder
$insertMany = Pricing::create(['name'=>request('name')]);
$insertMany->available()->createMany([
['service_id'=>1],
['service_id'=>2],
['service_id'=>3],
['service_id'=>4],
['service_id'=>5],
]);
class UsersTableSeeder extends Seeder
{
public function run()
{
$limit = env('SEEDER_LIMIT', 1);
echo $this->limit;
}
}
//In terminal run:
SEEDER_LIMIT=10 php artisan db:seed --class=UsersTableSeeder