laravel eloquent doesn't use protected table name
<p>In my model i added protected $table, but when i'm going to use it laravel does't use it. This is my role models:</p>

<pre><code>class Role extends Model
{
    protected $table = 'role';

    protected $primaryKey = 'ROLE_ID';

    protected $casts = [
        'ACTIVE' =&gt; 'boolean',
    ];

    protected $fillable = [
        'ROLE', 'ACTIVE', 'TYPE'
    ];

    public $timestamps = false;

    public function groups()
    {
        return $this-&gt;belongsToMany(Group::class, GroupRole::class, 'ROLE_ID', 'GROUP_ID');
    }
}
</code></pre>

<p>And this is Group model:</p>

<pre><code>class Group extends Model
{
    protected $table = 'groups';

    protected $primaryKey = 'GROUP_ID';

    protected $fillable = [
        'GROUP_ID', 'GROUP_NAME', 'PARENT_GROUP', 'ACTIVE'
    ];

    protected $casts = [
        'ACTIVE' =&gt; 'boolean',
    ];

    public $timestamps = false;

    public function type()
    {
        return $this-&gt;belongsTo(GroupType::class, 'TYPE', 'TYPE_ID');
    }

    public function roles()
    {
        return $this-&gt;belongsToMany(Role::class, GroupRole::class, 'GROUP_ID', 'ROLE_ID');
    }
}
</code></pre>

<p>And this is group_role table model. It handles many to many relation between role and group:</p>

<pre><code>class GroupRole extends Model
{
    protected $table = 'group_role';

    protected $primaryKey = 'GROUP_ROLE_ID';

    protected $fillable = [
        'COMMENT', 'ROLE_ID', 'GROUP_ID'
    ];

    public $timestamps = false;
}
</code></pre>

<p>Problem begin when i want to use this models. For example:</p>

<pre><code>$role = App\Role::first();
$groups = $role-&gt;groups;
</code></pre>

<p>Laravel returns this error messages:</p>

<blockquote>
  <p>SQLSTATE[42S02]: Base table or view not found: 1146 Table 'favian_mydb.App\GroupRole' doesn't exist (SQL: select <code>groups</code>.*, <code>App\GroupRole</code>.<code>ROLE_ID</code> as <code>pivot_ROLE_ID</code>, <code>App\GroupRole</code>.<code>GROUP_ID</code> as <code>pivot_GROUP_ID</code> from <code>groups</code> inner join <code>App\GroupRole</code> on <code>groups</code>.<code>GROUP_ID</code> = <code>App\GroupRole</code>.<code>GROUP_ID</code> where <code>App\GroupRole</code>.<code>ROLE_ID</code> = 1)</p>
</blockquote>

<p>I tried to replace App\GroupRole with group_role and executing in mysql. It works fine. Am i missing something?</p>