mercredi 19 juillet 2017

How to get relationship of the pivot table with eloquent

How to get relationship of the pivot table with eloquent.

$questions = Question::with('teams')->get();

This gets me the list of all questions along with teams.Now i need to get the list of players in any particular team.

Relation in Team Model.

public function players()
{
   return $this->hasMany(Player::class,'player_id');
}

Table relations



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2tpnx4R
via IFTTT

Aucun commentaire:

Enregistrer un commentaire