我可以从此模型工厂中删除名称吗?
$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10),
];
});
因为我编写单元测试并在其中创建用户并且我收到此错误 PDOException:SQLSTATE [42S22]:找不到列:1054未知列' name'在'字段列表' 我的用户模型由firstname和lastname
组成答案 0 :(得分:0)
这意味着你没有" name"数据库表中的字段。如果你有"名字"和"姓氏"表格中的字段应该填写它们:
$factory->define(App\User::class, function (Faker\Generator $faker) {
return [
'firstname' => $faker->firstName,
'lastname' => $faker->lastName,
'email' => $faker->email,
'password' => bcrypt(str_random(10)),
'remember_token' => str_random(10),
];
});