如何解决Laravel 播种机卡住并返回 ErrorException 数组哟字符串转换
public function up()
{
Schema::create('settings',function (Blueprint $table) {
$table->id();
$table->string('name',40)->unique();
$table->json('value');
$table->timestamps();
});
//seeder to insert FTP settings
DB::table("settings")->insert([
'name' => 'FTP_SETTINGS','value' => ['host' => '192.168.5.190','username'=> 'Alessandro','password' => 'Alessandro','port' => '21']
]);
}
之后我正在使用播种机进行此迁移(我也将其放入播种机部分,但存在相同的问题)但我将 ErrorException 数组转换为字符串。 可能是有价值的东西,但我不明白我做错了什么......非常感谢你的帮助。
解决方法
您正在尝试将数组值插入到 json 文件中。
Try instead:
DB::table("settings")->insert([
'name' => 'FTP_SETTINGS','value' => json_encode(['host' => '192.168.5.190','username'=> 'Alessandro','password' => 'Alessandro','port' => '21'])
]);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。