A
A
Alexander2016-03-17 10:34:17
Laravel
Alexander, 2016-03-17 10:34:17

How to fix error after garter belongsToMany?

there are fields in the table - users, roles and role_user.
Garter in the User model

public function roles()
    {
        return $this->belongsToMany('App\Models\Role');
    }

after garter, an error pops up:
BadMethodCallException in Builder.php line 2093:
Call to undefined method Illuminate\Database\Query\Builder::descendants()

I can't figure out what's wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2016-03-17
@Nc_Soft

Either name the table roles_users or
return $this->belongsToMany('App\ Models \Role', 'role_user');

V
Vyacheslav Plisko, 2016-03-17
@AmdY

You did not provide the necessary piece of code where you pull this link.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question