Skip to content

Commit

Permalink
Added a has method to UserCollection.
Browse files Browse the repository at this point in the history
  • Loading branch information
warrickbayman committed Jun 7, 2022
1 parent d607257 commit 0328766
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.2.4] 2022-06-07
### Added
- Added a `has` method to `UserCollection` which is really just an alias of `anyHave`.

## [2.2.3] 2022-06-06
### Added
- Added a `describe` method to the `User` class to get user permissions with descriptions.
Expand Down
5 changes: 5 additions & 0 deletions src/UserCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public function anyHave(...$permissions): bool
return false;
}

public function has($permission): bool
{
return $this->anyHave($permission);
}

/**
* Check if none of the users have the specified permissions.
*
Expand Down
1 change: 1 addition & 0 deletions tests/PermissionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ public function it_can_assign_permissioins_to_multiple_users(): void
self::assertTrue(Deadbolt::user($users[0])->has('articles.create'));
self::assertTrue(Deadbolt::user($users[1])->has('articles.create'));

self::assertTrue(Deadbolt::users($users)->has('articles.create'));
self::assertTrue(Deadbolt::users($users)->allHave('articles.create'));
self::assertFalse(Deadbolt::users($users)->allHave('articles.edit'));
self::assertTrue(Deadbolt::users($users)->anyHave('articles.create'));
Expand Down

0 comments on commit 0328766

Please sign in to comment.