laravelista / comments

Native comments for your Laravel application.
MIT License
744 stars 142 forks source link

Get the comment's post #141

Closed eduardonwa closed 3 years ago

eduardonwa commented 3 years ago

I dont think this is explained in the documentation (maybe it doesn't need to) but what im trying to do is, get a post from a list of comments. I been trying to reference the "commentable_type" column but it only displays the Post model path as a string ("App\Models\Post"), but I want to jump straight into the post in case there is a question for me, how would I do this?

mabasic commented 3 years ago
$comment->commentable

Will return the model you want.

It is in the Laravel documentation under Polymorphic relationships.