Level 1
I found the solution, I must change
->with('country')
to
->with('league.country')
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi! How can I make a select of three tables? 1st table: fixtures with league_id 2nd table: leagues with countries_id 3rd table: country
Now I want to select fixtures with league und and with country. But I can't get the country.
$fixtureDB = new \App\Fixture();
$fixtures = $fixtureDB
->with('league')
->with('country')
And the model fixture with:
public function league()
{
return $this->belongsTo('App\League');
}
public function country()
{
return $this->hasManyThrough('App\Country', 'App\League');
}
Where is my mistake?
I found the solution, I must change
->with('country')
to
->with('league.country')
Please or to participate in this conversation.