mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2024-12-27 22:45:27 +03:00
942b8fefb4
Using PSR-2 standard.
23 lines
603 B
Plaintext
23 lines
603 B
Plaintext
<?php
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Faker\Factory as Faker;
|
|
|
|
class {{name}} extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
$faker = Faker::create();
|
|
|
|
$firstIds = DB::table('{{first_table}}')->lists('id');
|
|
$secondIds = DB::table('{{second_table}}')->lists('id');
|
|
|
|
for($i = 0; $i < {{count}}; $i++) {
|
|
DB::table('{{first_resource}}_{{second_resource}}')->insert([
|
|
'{{first_resource}}_id' => $faker->randomElement($firstIds),
|
|
'{{second_resource}}_id' => $faker->randomElement($secondIds)
|
|
]);
|
|
}
|
|
}
|
|
}
|