Laravel 9 尝试在保存到数据库时访问 int 类型值的数组偏移量
Laravel 9 trying to access array offset on value of type int when save to database
我的问题是何时执行此操作 --->
$response = Http::post('api', ['code' => $api['code']]);
$datas = json_decode($response, true);
<pre> foreach ($datas as $data)
{
$info = new Info();
$info['country'] = $data['country'];
$info['code'] = $data['code'];
$info['confirmed'] = $data['confirmed'];
$info['recovered'] = $data['recovered'];
$info['critical'] = $data['critical'];
$info['deaths'] = $data['deaths'];
$info->save();
}
</code>
我收到一个错误 :: 试图访问 int 类型值的数组偏移量
我怎样才能解决这个问题?我尝试将其保存到数据库(这是来自 post 方法)
我的国家和代码表有 'string' 类型并确认恢复等下面是 bigInteger 类型?有什么问题吗??
已解决,删除解码参数以获取对象(此post方法使用对象)
我的问题是何时执行此操作 --->
$response = Http::post('api', ['code' => $api['code']]);
$datas = json_decode($response, true);
<pre> foreach ($datas as $data)
{
$info = new Info();
$info['country'] = $data['country'];
$info['code'] = $data['code'];
$info['confirmed'] = $data['confirmed'];
$info['recovered'] = $data['recovered'];
$info['critical'] = $data['critical'];
$info['deaths'] = $data['deaths'];
$info->save();
}
</code>
我收到一个错误 :: 试图访问 int 类型值的数组偏移量 我怎样才能解决这个问题?我尝试将其保存到数据库(这是来自 post 方法) 我的国家和代码表有 'string' 类型并确认恢复等下面是 bigInteger 类型?有什么问题吗??
已解决,删除解码参数以获取对象(此post方法使用对象)