Answer the question
In order to leave comments, you need to log in
How to establish two one-to-many relationships in Laravel?
There is a table Dot_tasks
In it columns responsible_id and autor_id
Each of the columns indicates the user id from the table Users
Users and Dot_tasks relate to each other as one to many. How to establish a connection in models?
Answer the question
In order to leave comments, you need to log in
Controller:
public function autors(){ // Зависит от того как у тебя модели называются
$users = User::with('autor')->get();
dd($users); //Заходишь в realtination и видишь связку
}
public function autor{
return $this->hasMany('App\Dot_tasks', 'autor_id', 'id'); //Зависит как у тебя модель называется
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question