У меня 5 моделей с одной сводной таблицей Country
Province
City
Area
Tour
tour_location
. Как добиться ниже функциональности?
$country->tours
$province->tours
$city->tours
$area->tours
Country.php Провинции HasMany
public function provinces()
{
return $this->hasMany('App\Province', 'country_id', 'id');
}
Province.php HasMany Города
public function cities()
{
return $this->hasMany('App\City', 'province_id', 'id');
}
City.php Области HasMany
public function areas()
{
return $this->hasMany('App\Area', 'city_id', 'id');
}
Area.php Принадлежит к многим турам
public function tours()
{
return $this->belongsToMany('App\Tour', 'tour_locations');
}