does laravel knows that the plural of country is countries ?
i have 3 tables ;
countries --id --name , regions --id --name ; country_region --country_id --region_id
how can i setup a manytomany relation ship .
Yup. You can test things like this using tinker too.
php artisan tinker
Psy Shell v0.8.11 (PHP 7.1.6 — cli) by Justin Hileman
>>> str_plural('country');
=> "countries"
In your Country model add:
public function getRegions()
{
return $this->belongsToMany('App\Region');
}
In your Region model add
public function getCountries()
{
return $this->belongsToMany('App\Country');
}
This will use the pivot table as expected.
Please or to participate in this conversation.