Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign Permission function cannot be found on Role Model #214

Open
DamPe88 opened this issue Apr 26, 2017 · 3 comments
Open

Assign Permission function cannot be found on Role Model #214

DamPe88 opened this issue Apr 26, 2017 · 3 comments

Comments

@DamPe88
Copy link

DamPe88 commented Apr 26, 2017

When trying the module on Laravel 5.4 and when allocating permission to the selected Role, assignPermission is not found.following your wiki on this.

$permUser  = Permission::find(1);
$roleAdmin = Role::first();
$roleAdmin->assignPermission($permUser);

no errors, but couldn't find details on the database table.
When i look at the model, assignPermission function is not there.could you please let me know why.am i doing anything wrong here?

Thanks
Dami

@DamPe88 DamPe88 changed the title Assign Permission function cannot be found on Role N=Model Assign Permission function cannot be found on Role Model Apr 27, 2017
@moransk8
Copy link

I have the same problem. I got an error "Method assignPermission does not exist." and I check on the Role class and there isn't a method with that name.

@kodeine
Copy link
Owner

kodeine commented Oct 30, 2017

@DamPe88 @moransk8 i'll take a look. meanwhile if you found a fix, please post a PR. Thanks

@moransk8
Copy link

@kodeine The problem was that I was using the method get() instead of first() when instantiating the role and this get you back an array so I changed it to first() and it works great.
eg:
$roleAdmin = Role::where('name', '=', 'Admin')->get(); // here you can't call the method to assign permission
$roleAdmin = Role::where('name', '=', 'Admin')->first(); // I changed to first() and works great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants