2016-02-22 02:38:41 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
use Faker\Factory as Faker;
|
|
|
|
|
|
|
|
class {{name}} extends Seeder
|
|
|
|
{
|
|
|
|
public function run()
|
|
|
|
{
|
2016-03-30 10:42:16 +03:00
|
|
|
$faker = Faker::create();
|
2016-02-22 02:38:41 +03:00
|
|
|
|
2016-03-30 10:42:16 +03:00
|
|
|
$firstIds = DB::table('{{first_table}}')->lists('id');
|
|
|
|
$secondIds = DB::table('{{second_table}}')->lists('id');
|
2016-02-22 02:38:41 +03:00
|
|
|
|
|
|
|
for($i = 0; $i < {{count}}; $i++) {
|
2016-03-30 10:42:16 +03:00
|
|
|
DB::table('{{first_resource}}_{{second_resource}}')->insert([
|
|
|
|
'{{first_resource}}_id' => $faker->randomElement($firstIds),
|
|
|
|
'{{second_resource}}_id' => $faker->randomElement($secondIds)
|
|
|
|
]);
|
2016-02-22 02:38:41 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|