问题是修补匠没有将内容包装在字符串中
使用消息'SQLSTATE [HY000] 照亮/数据库/查询异常:一般错误:1364 字段'address_line_2'没有默认值(SQL:插入( 、、、、、、、、、
Test
)name
值( emitchell 、dariana66@gender
hotmail . com, Kendra Friesen, Ole Carter, Gennaro Hickle, Prof. Brandon Herman 博士, 2018-12-21 01:07:12, 2018-12-21 01:07:12))'mobile_phone
alternate_phone
status
address_line_1
updated_at
created_at
如果我手动将引号添加到每个值,例如
values ('emitchell', 'dariana66@hotmail.com', 'Kendra
Friesen', 'Ole Carter', 'Gennaro Hickle', 'Prof. Brandon Herman PhD',
'2018-12-21 01:07:12', '2018-12-21 01:07:12')
有用
如何使修补程序在引号中生成随机内容?
我什至用(string)
$factory->define(App\Test::class, function (Faker $faker) {
return [
'name' => (string)$faker->sentence(),
'gender' => (string)$faker->sentence(),
'mobile_phone' => (string)$faker->sentence(),
'alternate_phone' => (string)$faker->sentence(),
'status' => (string)$faker->sentence(),
'address_line_1' => (string)$faker->sentence(),
'address_line_2' => (string)$faker->sentence(),
'town_city' => (string)$faker->sentence(),
'postscode' => (string)$faker->sentence(),
'notes' => (string)$faker->sentence()
];
});
或来自 github 页面的示例
'name' => $faker-> sentence($nbWords = 6, $variableNbWords = true), // 'Sit vitae voluptas sint non voluptates.'
它不会输出字符串值...
到底是怎么回事 ?