我有这个收藏
Collection {#611
#items: array:1 [
0 => Payeur {#605
#guarded: array:1 [
0 => "id"
]
#attributes: array:11 [
"id" => 1
"prenom_payeur" => "aymen"
"nom_payeur" => "larabi"
"mobile_payeur" => "non"
"telephone" => 230493212
"observation" => "jeflolena"
"adresse" => "jdjfnrll"
"event_id" => 1
"adherent_id" => 3
"created_at" => "2019-12-22 14:57:43"
"updated_at" => "2019-12-22 14:57:43"
]
}
]
}
,我想从该集合中获取nom_payeur
属性。我之前做了很多次,但我不知道为什么会收到此错误:
(此集合实例上不存在属性[nom_payeur]。)
我正在尝试通过以下操作获取属性:$payeur->nom_payeur
,$ payeur是集合。
请帮忙。
答案 0 :(得分:0)
try this hope its help
you have the collection and you try to access this property that is not possible beacuse in collection you can n't access element or attribute directly you have to use the array of index for this to access the poperty.
$payeur -> is collection this is incorrect way to access the property.
try this to access the attribute property.
$payeur[0]->nom_payeur