Well, comment is just a model here. So basically it works the same as all the other relationships
class Comment extends Model
{
public function commentMessages():
{
return $this->hasMany(CommentMessage::class);
}
public function posts():
{
return $this->hasMany(CommentPost::class);
}
public function ratings():
{
return $this->hasMany(CommentRating::class);
}
}
class CommentMessage extends Model
{
public function comment()
{
$this->belongsTo(Comment::class);
}
}
class CommentPost extends Model
{
public function comment()
{
$this->belongsTo(Comment::class);
}
}
class CommentRating extends Model
{
public function comment()
{
$this->belongsTo(Comment::class);
}
}
Documentation: https://laravel.com/docs/6.x/eloquent-relationships#one-to-many