我有一个集合,其中有一个数组作为项目,我想知道如何在我的代码中访问它,这是集合的dd
:
Collection {#990
#items: array:1 [
0 => RoomPricingHistory {#971
#fillable: array:19 [
0 => "accommodation_room_id"
1 => "net_price"
2 => "sales_price"
3 => "extra_bed_price"
4 => "half_charge_price"
5 => "half_board_price"
6 => "full_board_price"
7 => "foreign_net_price"
8 => "foreign_sales_price"
9 => "foreign_extra_bed_price"
10 => "foreign_half_charge_price"
11 => "foreign_half_board_price"
12 => "foreign_full_board_price"
13 => "operator_id"
14 => "commission_percent"
15 => "discount_percent"
16 => "from_date"
17 => "to_date"
18 => "is_deleted"
]
#connection: "mysql"
#table: "room_pricing_histories"
#primaryKey: "id"
这是我尝试的代码:
$sum_price[] = $room_price[$i]->sales_price;
它在for循环中,但出现此错误:
此集合实例上不存在属性[sales_price]。