Answer the question
In order to leave comments, you need to log in
Laravel. How to attach user to comments?
there are 3 tables
posts
id,name
comments
id, post_id, user_id
user
id,name,image
$post = Post::where("alias", $alias)->first();
$comments = $post->comments;
public function comments()
{
return $this->hasMany('App\Post', 'post_id');
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question