Я пытаюсь заполнить данные, как указано в этой ссылке https://github.com/fzaninotto/Faker. Таблицы заполнены, но я получил эту ошибку:
$ php artisan db:seed
Seeding: gamesSeeder
Method Illuminate\Database\Query\Builder::issues does not exist.
Я использую Lumen (5.6.3) (Компоненты Laravel 5.6. *).
<?php
$factory->define(App\teams::class, function (Faker\Generator $faker) {
return [
'name' => $faker-> word,
];
});
$factory->define(App\games::class, function (Faker\Generator $faker) {
return [
'Team 1' => $faker-> word,
'Team 2' => $faker-> word,
'Score 1' => $faker->numberBetween($min = 0, $max = 10),
'Score 2' => $faker->numberBetween($min = 0, $max = 10),
'Game Date' => $faker->date($format = 'Y-m-d', $max = 'now'),
'Viewers' => $faker-> numberBetween($min = 0, $max = 100000),
];
});
Вот мои файлы сеялок.
teamsSeeder:
<?php
use Illuminate\Database\Seeder;
class gamesSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\games::class, 30)->create()->each(function($u) {
$u->issues()->save(factory(App\games::class)->make());
});
}
}
а вот игры Отправитель
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use App\teams;
class teamsSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
factory(App\teams::class, 5)->create()->each(function($u) {
$u->issues()->save(factory(App\teams::class)->make());
});
}
}