调用未定义的方法Illuminate \ Database \ Query \ Builder :: posts()

时间:2016-04-28 05:42:21

标签: php laravel-5.2

我正在尝试种子数据库代码如下

<?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()

任何帮助表示赞赏

0 个答案:

没有答案