Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anizou's avatar

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 .

0 likes
3 replies
isaackearl's avatar

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"
RayC's avatar

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.