【发布时间】:2018-01-11 14:31:58
【问题描述】:
我想显示链接的 cmets 并显示 cmets 的 de 关系,即 user 和 userprofile...
dd($page->getRelation('links'));
Collection {#318 ▼
#items: array:2 [▼
0 => Link {#317 ▼
#relations: array:2 [▼
"comments" => Collection {#327 ▼
#attributes: array:5 [▼
"id" => 3
"content" => "teste"
"link_id" => 1
"user_id" => 1
"created_at" => "2018-01-11 00:47:32"
]
#relations: array:2 [▼
"user" => User {#330 ▶}
"userProfile" => UserProfile {#326 ▶}
]
}
]
}
在我提出的观点中:
@foreach($page->getRelation('links') as $link)
<div class="link">
<!--show de comments of link (ONLY FOR EXPLANATION)-->
@foreach()
<div class="comments">
SHOW DE ATTRIBUTE OF COMMENT AND ATTRIBUTE OF RELATIONS OF COMMENT (user, userprofile)
</div>
@endforeach
</div>
@endforeach
【问题讨论】:
标签: laravel