How can I get some data from 3 table using eloquent in laravel 5? I have 3 table, Team, Boards, User
Team Model
public function member()
{
return $this->belongsToMany(User::class)->withPivot('status','user_role')->withTimestamps();
}
public function boards()
{
return $this->belongsToMany(Boards::class)->withTimestamps();;
}
Boards Model
public function member()
{
return $this->belongsToMany(User::class)->withPivot('status','user_role')->withTimestamps();
}
public function team(){
return $this->belongsToMany(Team::class)->withTimestamps();
}
Table structure :
Team
id
team_name
Team_User (Pivot table)
id
user_id
team_id
Boards
id
board_name
Boards_user (pivot Table)
id
boards_id
user_id
The boards are belongs to team, and i want to get the data of boards that belong to a team (ex : team A) that assign to a user (ex: user1) but also member of team A. How can i accomplish that?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire