Skip to content

Commit 0461f75

Browse files
committed
Merge branch 'master' into 8.x
2 parents 1c1b404 + ca3f84b commit 0461f75

File tree

6 files changed

+56
-27
lines changed

6 files changed

+56
-27
lines changed

.github/workflows/tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,20 @@ jobs:
1212
fail-fast: false
1313
matrix:
1414
php: [8.1, 8.2, 8.3, 8.4]
15-
laravel: [10.*, 11.*]
15+
laravel: ["10.*", "11.*", "12.*"]
1616
stability: [prefer-lowest, prefer-stable]
1717
include:
1818
- laravel: 10.*
1919
testbench: ^8.20
2020
- laravel: 11.*
2121
testbench: ^9.0
22+
- laravel: 12.*
23+
testbench: ^10.0
2224
exclude:
2325
- php: 8.1
2426
laravel: 11.*
27+
- laravel: 12.*
28+
php: 8.1
2529

2630
name: PHP ${{ matrix.php }} - ${{ matrix.laravel }} - ${{ matrix.stability }}
2731

@@ -30,7 +34,7 @@ jobs:
3034
uses: actions/checkout@v2
3135

3236
- name: Cache dependencies
33-
uses: actions/cache@v1
37+
uses: actions/cache@v4
3438
with:
3539
path: ~/.composer/cache/files
3640
key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
## Version Compatibility
1212

13-
| Laravel | Laratrust |
14-
| :------------ | :-------------------------------------------------- |
15-
| 10.x, 11.X | [8.x](//laratrust.santigarcor.me/docs/8.x/) |
16-
| 9.x-10.x | [7.x](//laratrust.santigarcor.me/docs/7.x/) |
17-
| 8.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
18-
| 7.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
19-
| 6.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
20-
| 5.6.x - 5.8.x | [5.2](//laratrust.santigarcor.me/docs/5.2/) |
21-
| 5.3.x - 5.5.x | [5.1](//laratrust.santigarcor.me/docs/5.1/) |
22-
| 5.0.x - 5.2.x | [4.0](//github.com/santigarcor/laratrust/tree/4.0). |
13+
| Laravel | Laratrust |
14+
| :--------------- | :-------------------------------------------------- |
15+
| 10.x, 11.X, 12.X | [8.x](//laratrust.santigarcor.me/docs/8.x/) |
16+
| 9.x-10.x | [7.x](//laratrust.santigarcor.me/docs/7.x/) |
17+
| 8.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
18+
| 7.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
19+
| 6.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
20+
| 5.6.x - 5.8.x | [5.2](//laratrust.santigarcor.me/docs/5.2/) |
21+
| 5.3.x - 5.5.x | [5.1](//laratrust.santigarcor.me/docs/5.1/) |
22+
| 5.0.x - 5.2.x | [4.0](//github.com/santigarcor/laratrust/tree/4.0). |
2323

2424
## Installation, Configuration and Usage
2525

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@
2323
"require": {
2424
"php": ">=8.1",
2525
"kkszymanowski/traitor": "^1.0",
26-
"laravel/framework": "^10.0|^11.0"
26+
"laravel/framework": "^10.0|^11.0|^12.0"
2727
},
2828
"require-dev": {
2929
"mockery/mockery": "^1.3.2",
30-
"orchestra/testbench": "^8.0|^9.0",
31-
"phpunit/phpunit": "^8.4|^9.0|^10.5"
30+
"orchestra/testbench": "^8.0|^9.0|^10.0",
31+
"phpunit/phpunit": "^8.4|^9.0|^10.5|^11.5.3"
3232
},
3333
"autoload": {
3434
"psr-4": {

docs/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ Laratrust is an easy and flexible way to add roles, permissions and teams author
2020

2121
## Version Compatibility
2222

23-
| Laravel | Laratrust |
24-
| :------------ | :-------------------------------------------------------- |
25-
| 10.x, 11.X | [8.x](/docs/8.x/) |
26-
| 9.x-10.x | [7.x](/docs/7.x/) |
27-
| 8.x | [6.x](/docs/6.x/) |
28-
| 7.x | [6.x](/docs/6.x/) |
29-
| 6.x | [6.x](/docs/6.x/) |
30-
| 5.6.x - 5.8.x | [5.2](/docs/5.2/) |
31-
| 5.3.x - 5.5.x | [5.1](/docs/5.1/) |
32-
| 5.0.x - 5.2.x | [4.0](https://github.com/santigarcor/laratrust/tree/4.0). |
23+
| Laravel | Laratrust |
24+
| :--------------- | :-------------------------------------------------------- |
25+
| 10.x, 11.X, 12.X | [8.x](/docs/8.x/) |
26+
| 9.x-10.x | [7.x](/docs/7.x/) |
27+
| 8.x | [6.x](/docs/6.x/) |
28+
| 7.x | [6.x](/docs/6.x/) |
29+
| 6.x | [6.x](/docs/6.x/) |
30+
| 5.6.x - 5.8.x | [5.2](/docs/5.2/) |
31+
| 5.3.x - 5.5.x | [5.1](/docs/5.1/) |
32+
| 5.0.x - 5.2.x | [4.0](https://github.com/santigarcor/laratrust/tree/4.0). |
3333

3434
## What does Laratrust support?
3535

src/Laratrust.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,18 @@ public function hasPermission(
5151
return false;
5252
}
5353

54+
/**
55+
* Check if the current user has a permission by its name.
56+
* Alias to hasPermission.
57+
*/
58+
public function isAbleTo(
59+
string|array|BackedEnum $permission,
60+
mixed $team = null,
61+
bool $requireAll = false
62+
): bool {
63+
return $this->hasPermission($permission, $team, $requireAll);
64+
}
65+
5466
/**
5567
* Check if the current user has a role or permission by its name.
5668
*

tests/LaratrustFacadeTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
declare(strict_types=1);
44

5-
use Mockery as m;
65
use Laratrust\Laratrust;
7-
use Laratrust\Tests\Models\User;
86
use Laratrust\Tests\LaratrustTestCase;
7+
use Laratrust\Tests\Models\User;
8+
use Mockery as m;
99

1010
class LaratrustFacadeTest extends LaratrustTestCase
1111
{
1212
protected $laratrust;
13+
1314
protected $user;
1415

1516
protected function setUp(): void
@@ -45,6 +46,18 @@ public function testHasPermission()
4546
$this->assertFalse($this->laratrust->hasPermission('any_permission'));
4647
}
4748

49+
public function testIsAbleTo()
50+
{
51+
$this->laratrust->shouldReceive('user')->andReturn($this->user)->twice()->ordered();
52+
$this->laratrust->shouldReceive('user')->andReturn(null)->once()->ordered();
53+
$this->user->shouldReceive('hasPermission')->with('user_can', null, false)->andReturn(true)->once();
54+
$this->user->shouldReceive('hasPermission')->with('user_cannot', null, false)->andReturn(false)->once();
55+
56+
$this->assertTrue($this->laratrust->isAbleTo('user_can'));
57+
$this->assertFalse($this->laratrust->isAbleTo('user_cannot'));
58+
$this->assertFalse($this->laratrust->isAbleTo('any_permission'));
59+
}
60+
4861
public function testAbility()
4962
{
5063
$this->laratrust->shouldReceive('user')->andReturn($this->user)->twice()->ordered();

0 commit comments

Comments
 (0)