0 => Tour {#229 ▼
#table: "tour"
#...
#attributes: array:12 [▼
"id" => 6
"name" => "Nha Trang Tour"
"price" => 3500000.0
"price_promotion" => 0.0
"id_package" => 4
"id_location" => 8
"start_time" => "2018-01-27"
"end_time" => "2018-01-28"
"star" => 4.0
"description" => "Funny"
"created_at" => null
"updated_at" => "2017-12-29 00:00:00"
]
#...
}
1 => Tour {#230 ▶}
我需要在“#items”中的2个数组0和1中调用2个id_location
($sale['items']->id_location);
和
($sale->id_location);
但不能接受,而且我使用
($sale[0]->id_location);
然后成功,但只得到一个
谢谢你的帮助
使用pluck()
方法,如果它是一个集合,或使用array_pluck
,如果它是一个数组:
$sale->pluck('id_location');
array_pluck($sales, 'id_location');