我在尝试运行php artisan db:seed
时遇到以下错误。我之前运行了composer update
和composer dump-autoload
。
user.php的
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravel\Passport\HasApiTokens;
class User extends Authenticatable
{
use Notifiable, HasApiTokens;
protected $fillable = ['name', 'email', 'password',];
protected $hidden = ['password', 'remember_token',];
}
Address.php
use Illuminate\Database\Eloquent\Model;
class Address extends Model
{
protected $fillable = ['user_id', 'name', 'address','mobile_no','image','email'];
public function users() {
return $this->hasOne(User::class);
}
}
DatabaseSeeder.php
class DatabaseSeeder extends Seeder
{
public function run()
{
$this->call(UsersTableSeeder::class);
$this->call(AddressessTableSeeder::class);
}
}
UsersTableSeeder.php
class UsersTableSeeder extends Seeder
{
public function run()
{
factory(App\User::class,10)->create();
}
}
AddressessTableSeeder.php
class AddressessTableSeeder extends Seeder
{
public function run()
{
factory(\App\Address::class, 50)->create()->each(function ($u) {
$u->users()->save(factory(App\Post::class)->make());
});
}
}
这是我的模型和播种器文件。我无法找出错误出现的原因。