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:
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2V7d7kc
via IFTTT
Aucun commentaire:
Enregistrer un commentaire