I have 3 tables: regions, countries, tours
region has countries and country is related to a region
tours have countries and countries have tours.
Now I need Region has tours and tour has regions (tour can include more than one region depending upon countries it belongs to)
I know "Has Many Through" but this is usable when intermediate relation is one-to-many but my intermediate relation is many-to-many
I tried this
public function tours()
{
return $this->hasManyThrough(Tour::class, Country::class, "region_id", "country_id");
}
but "country_id" is not available in Tours table. Because Tours and Countries have many-to-many relation and country_id is in pivot table.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire