【发布时间】:2016-10-04 13:55:08
【问题描述】:
我有如下 JSON 格式,
{"projectId":"1","projectName":"My Project","total_project_cost":2200000,"total":2400000,"totalPercentFee":7,"adderArray":[{"name":"Adder 1","value":"100000","firmApercentage":"","firmBpercentage":""},{"name":"Adder 2","value":"100000","firmApercentage":"","firmBpercentage":""}]
在此插入 adderArray 我有用户 laravel $cast。
所以我的模型看起来像这样
protected $table = 'projects_percent_fee_management';
protected $casts = [
'adder_data' => 'array',
'project_breakdown' => 'array',
];
protected $fillable = ['project_id','company_id','total_project_cost','adder_data','total','total_percent_fee','project_breakdown','total_budget'];
Insert 运行良好,它在 adder_data 字段中正确插入了 adderArray 数据。
但是在更新时它给出了 preg_replace(): Parameter mismatch, pattern 是一个字符串,而替换是一个数组错误,并且在字段中它更新了“Array”。
【问题讨论】:
标签: laravel laravel-5.2