我正在尝试种子数据库代码如下
<?php
use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
class DatabaseSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
//DB::table('artists');
// factory(App\Artist::class, 50)->create();
factory(App\Artist::class, 10)
->create()
->each(function($u) {
$u->album()->save(factory(App\Album::class)->make());
});
Model::reguard();
}
}
错误
调用未定义的方法Illuminate \ Database \ Query \ Builder :: posts()
任何帮助表示赞赏