Php 使用laravel eloquent Create的服务器上的数组到字符串转换错误
首先,我必须告诉您,我的代码正在本地主机上运行,我得到的错误仅在部署后出现在开发服务器上 我在Php 使用laravel eloquent Create的服务器上的数组到字符串转换错误,php,mysql,laravel,eloquent,laravel-vue,Php,Mysql,Laravel,Eloquent,Laravel Vue,首先,我必须告诉您,我的代码正在本地主机上运行,我得到的错误仅在部署后出现在开发服务器上 我在$list=Listing::create($data)上遇到错误 这是我的$data有效载荷 array:25 [ "seller1_name" => "Seller 1" "seller2_name" => "Seller 2 test" "listing_date" =>
$list=Listing::create($data)上遇到错误代码>
这是我的$data有效载荷
array:25 [
"seller1_name" => "Seller 1"
"seller2_name" => "Seller 2 test"
"listing_date" => "2020-12-17"
"listing_expire_date" => "2020-12-29"
"address" => "New addrs"
"city" => "new city"
"state" => "new state"
"zip" => "1231231"
"list_price" => "4343434"
"step_template_id" => 8
"broker_fee_type" => "$"
"transaction_fee" => "342342342342"
"cobroker_split_type" => "$"
"school_district" => "dsadasad"
"broker_fee" => "3424234"
"cobroker_split" => "34243"
"agents" => array:2 [
0 => array:2 [
"key" => 78
"value" => "Agent1 user"
]
1 => array:2 [
"key" => 84
"value" => "Agent2 user"
]
]
"admin_id" => 68
"login_user_id" => 68
"login_email" => "webkeeda@yopmail.com"
"chargebee_plan_id" => "starter"
"customer_id" => "AzZlzTSI5w7bDEMt"
"role_id" => 1
"user_company" => null
"created_by" => 68
]
我的Listing.php模型具有多对多关系
public function agents()
{
return $this->belongsToMany('App\User', 'listing_agents', 'listing_id', 'agent_id');
}
如果你需要我这边的任何其他信息,请在评论中告诉我
编辑:
为了在我的关系中存储数据,我使用了这个
$agents = $request->agents;
array_walk($agents, function (& $item, $key, $listing) {
$item['listing_id'] = $listing->id;
$item['agent_id'] = $item['key'];
unset($item['key']);
}, $listing);
if($listing) {
$listing->listing_agents()->createMany($agents);
}
关系:
public function listing_agents()
{
return $this->hasMany('App\ListingAgent', 'listing_id');
}
你得到了什么错误?嗯代理
是一个数组。。。在Str上,我尝试使用$e->getTrace(),但它是一个很长的数据传输文件列表。无法准确获取错误的来源。我已更新了代码,以及在关系中存储数据的方式。在将代理
键传递到创建
之前,请完全删除/取消设置该键