I dont know if its called query reference. Feel free to make edits.
I have a polymorphic relation on my Article Model:
public function comments(){
return $this->morphMany(Comment::class, 'commentable');
}
Now I have to send a polymorphic relation data to my view.
public function show(Article $article)
{
return view('article.show',[
'article' => $article,
'comments' => $article->comments()
]);
}
I'm sending it by $article->comments() because I want to use each comments eloquent relations.
On my blade:
@foreach($comments as $comment)
//This won't execute. What is wrong?
@endforeach
if I dd(comments) before foreach I've this: 
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire