-
Notifications
You must be signed in to change notification settings - Fork 336
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
Can't get all abilities of role model #280
Comments
There isn't really enough information to go on here. Can you show me your full |
I have put the
And my
I also included Spaties activitylog here, but after extending the Bouncer Role model didn't work I put the log logic directly into the controller. I want to log the create, update and delete events of the model. |
Nothing I see here would suggest there's anything wrong. Are you sure your role actually has abilities assigned to it? |
Yes I'm sure. As I said if I user the Bouncer model directly I get all the abilities. I tried it in the artisan console and in the controller. Both times with the same effect.. |
To help you, I would need a clean, minimal reproduction of this problem.
In all, there should be exactly 3 commits, so that it's easy to read through it and see whats what. Enjoy! |
Hi! |
I had a similar problem. The In my case the problem was that I did not call // AppServiceProvider.php -> boot()
\Bouncer::useRoleModel(App\Role::class); |
I'm still not clear what the issue is here. Anyway, it may be related to this. If so, try registering your custom model with the morph map: use Bouncer;
use App\Role;
use Illuminate\Database\Eloquent\Relations\Relation;
public function boot()
{
Bouncer::useRoleModel(Role::class);
Relation::morphMap([Role::class]);
} |
Is this still an issue after registering your custom models with the morph map? |
This works for me, |
Hey again,
I got another interresting one... 😃
I created a custom role model in the App directory. I just extended the default Bouncer role model and added some functions and another package to log activity on the model (create, update, delete).
I implemented it like suggested here: #13
First I didn't register the Bouncer::useRoleModel() in the AppServiceProvider. Everything seemed to work fine, but the getAbilties() function returned an empty collection when used on my custom model.
Then I went on and registered the Bouncer::useRoleModel() in the AppServiceProvider. Now the getAbilities() function doesn't work on Bouncer anymore too.
This time I have now clue how this happened. I actually tried a lot of things like implementing the Traits directly and so on, nothing worked..
Kind regards,
Finn Janik
The text was updated successfully, but these errors were encountered: