I'm building a website that involves a schedule of basketball games. I have 2 tables for this: teams
and games
.
As for the relationships between the models. For Game I got this:
public function homeTeam()
{
return $this->belongsTo('App\Team\Team', 'home_team');
}
public function awayTeam()
{
return $this->belongsTo('App\Team\Team', 'away_team');
}
But what should I do for the Team model? By the games()
method inside it, I want to get all the team's games, home and away, and for this I need to reference both home_team
and away_team
columns on the games
table.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire