xxxxxxxxxx
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
DB::table('users')->insert([
'name' => 'John Doe',
'email' => 'john@doe.com',
'password' => Hash::make('password')
]);
xxxxxxxxxx
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
xxxxxxxxxx
$insertMany = Pricing::create(['name'=>request('name')]);
$insertMany->available()->createMany([
['service_id'=>1],
['service_id'=>2],
['service_id'=>3],
['service_id'=>4],
['service_id'=>5],
]);
xxxxxxxxxx
Database seeder is used to populate tables with data.
Model factories is a convenient centralized place to define how your models should be populated with fake data.
In seeder class you would leverage model factories, and model factories will most likely use another library to generate random fake data, such as fzaninotto/faker.