@@ 13-26 (lines=14) @@ | ||
10 | ||
11 | private $requiredPermissions = []; |
|
12 | ||
13 | public static function forRoles(array $roles): self |
|
14 | { |
|
15 | $message = 'User does not have the right roles.'; |
|
16 | ||
17 | if (config('permission.display_permission_in_exception')) { |
|
18 | $permStr = implode(', ', $roles); |
|
19 | $message = 'User does not have the right roles. Necessary roles are '.$permStr; |
|
20 | } |
|
21 | ||
22 | $exception = new static(403, $message, null, []); |
|
23 | $exception->requiredRoles = $roles; |
|
24 | ||
25 | return $exception; |
|
26 | } |
|
27 | ||
28 | public static function forPermissions(array $permissions): self |
|
29 | { |
|
@@ 28-41 (lines=14) @@ | ||
25 | return $exception; |
|
26 | } |
|
27 | ||
28 | public static function forPermissions(array $permissions): self |
|
29 | { |
|
30 | $message = 'User does not have the right permissions.'; |
|
31 | ||
32 | if (config('permission.display_permission_in_exception')) { |
|
33 | $permStr = implode(', ', $permissions); |
|
34 | $message = 'User does not have the right permissions. Necessary permissions are '.$permStr; |
|
35 | } |
|
36 | ||
37 | $exception = new static(403, $message, null, []); |
|
38 | $exception->requiredPermissions = $permissions; |
|
39 | ||
40 | return $exception; |
|
41 | } |
|
42 | ||
43 | public static function forRolesOrPermissions(array $rolesOrPermissions): self |
|
44 | { |
|
@@ 43-56 (lines=14) @@ | ||
40 | return $exception; |
|
41 | } |
|
42 | ||
43 | public static function forRolesOrPermissions(array $rolesOrPermissions): self |
|
44 | { |
|
45 | $message = 'User does not have any of the necessary access rights.'; |
|
46 | ||
47 | if (config('permission.display_permission_in_exception') && config('permission.display_role_in_exception')) { |
|
48 | $permStr = implode(', ', $rolesOrPermissions); |
|
49 | $message = 'User does not have the right permissions. Necessary permissions are '.$permStr; |
|
50 | } |
|
51 | ||
52 | $exception = new static(403, $message, null, []); |
|
53 | $exception->requiredPermissions = $rolesOrPermissions; |
|
54 | ||
55 | return $exception; |
|
56 | } |
|
57 | ||
58 | public static function notLoggedIn(): self |
|
59 | { |