JavaScript
2
Вклад в тег
Comment (article_id, id, text, user_id)
Article (id, text, user_id)
User (id, name)
public function comments(){
return $this->hasMany(Comment::class);
}
public function author(){
return $this->belongsTo(User::class);
}
public function commetators(){
return $this->hasManyThrough(User::class, Comment::class);
public function article(){
return $this->belongsTo(Article::class);
}
public function user(){
return $this->belongsTo(User::class);
}
$users = Article::find(1)->commentators;