因此,我使用以下数组传入$record params,但当 API 的特定返回为 null 时出现错误。
这是数组:
$office->load([
'post_title' => $record->office,
'location_id' => $record->location_id,
'location' => $record->location,
'business_unit' => $record->business_unit,
'type_id' => $record->type_id,
'brand_id' => $record->brand_id,
]);
我的$record->brand_id返回为 null 并且它使我的整个脚本崩溃,有没有一种方法可以将 null 输出为字符串并将 $record->brand_id 包装在某些东西中?
更新:
我最终配置了所需的东西brand_id,因为$record->brand_id ?? $default_value效果很好!
茅侃侃