How should I name an Eloquent polymorphic table?

eloquent, laravel

Solution

The convention is as you described, but Laravel doesn't force you into that naming convention. You're free to use whatever name you'd like as long as you make note of that in the model relationship like :

public function tags()
{
    return $this->morphToMany('App\Tag', 'taggable');
}

That being said, the convention would probably say you should write "companyable", as weird as that sounds.

Problem

I'm using Laravel eloquent to design my database. Eloquent has a naming convention for naming a many to many polymorphic relations. If the initial table's name is `comments`, then the pivot table should be named `commentable`. If it is `documents`, then `documentable` and so on. But how should I name my pivot table if the source table is `companies`?

Original source