1. In Laravel 9, the following error occurs: Indirect modification of overloaded property ReturnOrder::$order has no effect. As shown in Figure 1

JSON
{
"status_code": 500,
"code": 0,
"message": "Indirect modification of overloaded property ReturnOrder::$order has no effect",
"trace": {
"line": 648,
"file": "E:\\object\\ReturnOrderService.php",
"class": "ErrorException"
}
}
2. The code implementation is as follows
PHP
$item->order = $keyedOrders[$item->order_id] ?? null;
$item->order->returnOrders = $keyedOrderReturnOrders[$item->order_id] ?? new EloquentCollection();
2. The adjusted code implementation is as follows, and the error no longer occurs
PHP
$item->order = $keyedOrders[$item->order_id] ?? null;
if ($item->order) {
$item->order->returnOrders = $keyedOrderReturnOrders[$item->order_id] ?? new EloquentCollection();
}
