|
4 | 4 | use AuroraWebSoftware\AAuth\Models\OrganizationNode; |
5 | 5 | use AuroraWebSoftware\AAuth\Models\Role; |
6 | 6 |
|
7 | | -if (!function_exists('aauth')) { |
| 7 | +if (! function_exists('aauth')) { |
8 | 8 | function aauth(): AAuth |
9 | 9 | { |
10 | 10 | return app('aauth'); |
11 | 11 | } |
12 | 12 | } |
13 | 13 |
|
14 | | -if (!function_exists('aauth_can')) { |
| 14 | +if (! function_exists('aauth_can')) { |
15 | 15 | function aauth_can(string $permission, mixed ...$arguments): bool |
16 | 16 | { |
17 | 17 | return app('aauth')->can($permission, ...$arguments); |
18 | 18 | } |
19 | 19 | } |
20 | 20 |
|
21 | | -if (!function_exists('aauth_has_role')) { |
| 21 | +if (! function_exists('aauth_has_role')) { |
22 | 22 | function aauth_has_role(string $roleName): bool |
23 | 23 | { |
24 | 24 | return app('aauth')->currentRole()?->name === $roleName; |
25 | 25 | } |
26 | 26 | } |
27 | 27 |
|
28 | | -if (!function_exists('aauth_active_role')) { |
| 28 | +if (! function_exists('aauth_active_role')) { |
29 | 29 | function aauth_active_role(): ?Role |
30 | 30 | { |
31 | 31 | return app('aauth')->currentRole(); |
32 | 32 | } |
33 | 33 | } |
34 | 34 |
|
35 | | -if (!function_exists('aauth_active_organization')) { |
| 35 | +if (! function_exists('aauth_active_organization')) { |
36 | 36 | function aauth_active_organization(): ?OrganizationNode |
37 | 37 | { |
38 | 38 | $nodeIds = app('aauth')->organizationNodeIds(); |
39 | 39 | if (empty($nodeIds)) { |
40 | 40 | return null; |
41 | 41 | } |
| 42 | + |
42 | 43 | return OrganizationNode::find($nodeIds[0]); |
43 | 44 | } |
44 | 45 | } |
45 | 46 |
|
46 | | -if (!function_exists('aauth_is_super_admin')) { |
| 47 | +if (! function_exists('aauth_is_super_admin')) { |
47 | 48 | function aauth_is_super_admin(): bool |
48 | 49 | { |
49 | 50 | return app('aauth')->isSuperAdmin(); |
|
0 commit comments