New
-
Forbid abilities. You can now forbid abilities for more granular control. 865227b
Bouncer::allow($user)->to('delete', Post::class); $post1 = Post::where('title', 'Regular post')->first(); $post2 = Post::where('title', 'Very important post')->first(); Bouncer::forbid($user)->to('delete', $post2); Bouncer::allows('delete', $post1); // true Bouncer::allows('delete', $post2); // false
Here's another example:
Bouncer::allow('superadmin')->everything(); Bouncer::allow('admin')->everything(); Bouncer::forbid('admin')->toManage(User::class);
The
admin
role can now do everything, besides managing users. -
Easily add a title to an ability. You can now pass additional attributes for the ability model being created. 7036b52
Bouncer::allow($user)->to('edit', Post::class, [ 'title' => 'Edit all posts', ]);
-
Bouncer factory. It is now easier than ever to use bouncer outside of Laravel. a1b7137
$bouncer = Bouncer::create(); // use $bouncer $bouncer->allow($user)->to('access-dashboard');
You can also pass along a
$user
instance to be able to check abilities for that user:$bouncer = Bouncer::make()->withUser($user)->create(); $bouncer->allows('access-dashboard');
Breaking Changes
- Removed exclusivity option. 280d7bb