I am using Laravel Commentable that uses Baum
Post Model
class Post extends Model
{
use Commentable;
....
My user model name is User
Comment table structure:
The user_id
stores the user id of the user who commented, commentable_id
stores the post id of the post where the comment was placed.
The Comments are working as expected.
I am able to insert comments, delete comments.
To display the comments:
$comments = Comment::orderBy('id', 'desc')->get();
@foreach($comments as $comment)
{{ $comment->user->name }} : {{ $comment->body }}
@endforeach
This gives me the name and the comment by the user in the view.
Question: How to get the post model attributes from a comment?
{{ $comment->post->slug }}
<-this doesn't works