I am trying to return a list of fixtures that have a team associated to them. The home team field in the fixtures table references the id on the team table and the same for the away team field:
teams
-------
id (int, primary)
name (varchar[255])
fixtures
-------
id (int, primary)
hometeam (int - references `id` on `teams`)
awayteam (int - references `id` on `teams`)
date (datetime)
I have a fixtures and team model seperately, at the moment I am only able to return the team id in the fixtures table and not the name associated to it from the team table. I believe this is because the magic models look for the same name as the field name, i.e. team instead of hometeam or awayteam.
Is there anyway I can get this to wor with eloquent or does it need an old fashioned join?
Thanks in advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire