-
Notifications
You must be signed in to change notification settings - Fork 327
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
Add method in Role model #13
Comments
You can add your own methods to the role model by extending it: namespace App;
use Silber\Bouncer\Database\Role as BaseRole;
class Role extends BaseRole
{
public function scopeOrderedList($query)
{
return $query->orderBy('name')->lists('name', 'id');
}
} Once you've created your own extended model, simply tell Bouncer to use it: Bouncer::useRoleModel(\App\Role::class); Stick that into your |
Excellent! That keeps things clean. Thanks! And I really like Bouncer, perfect for an app I'm working on! |
Hi, is this still the way to go? Because with last versions (Laravel 5.5.14, Bouncer v1.0.0-beta.4) if I change the RoleModel with Bouncer::useRoleModel(\App\Role::class), I get "This action is unauthorized". Thanks! Edit: The problem was that the permission table had "roles" for entity_type, and now it should be "App\Modes\Role", which is my namespace. Odd that it wasn't originally "Silber\Bouncer\Database\Role" |
Hello,
Would it be possible to have a scope method added to the Role model to return a list of available roles? Something like this for example
For example, this would be useful when building select boxes for someone to choose a role from.
Then pass that into a view.
Thanks
The text was updated successfully, but these errors were encountered: