File tree 2 files changed +5
-8
lines changed
2 files changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,9 @@ public function __construct(Guard $auth)
35
35
*
36
36
* @return mixed
37
37
*/
38
- public function handle ($ request , Closure $ next , $ permission )
38
+ public function handle ($ request , Closure $ next , ... $ permission )
39
39
{
40
- if ($ this ->auth ->check () && $ this ->auth ->user ()->hasPermission ($ permission )) {
40
+ if ($ this ->auth ->check () && $ this ->auth ->user ()->hasPermission (join ( ' , ' , $ permission) )) {
41
41
return $ next ($ request );
42
42
}
43
43
Original file line number Diff line number Diff line change @@ -35,13 +35,10 @@ public function __construct(Guard $auth)
35
35
*
36
36
* @return mixed
37
37
*/
38
- public function handle ($ request , Closure $ next , $ role )
38
+ public function handle ($ request , Closure $ next , ... $ role )
39
39
{
40
- $ roles = explode ('| ' , $ role );
41
- for ($ i = 0 ; $ i < count ($ roles ); $ i ++) {
42
- if ($ this ->auth ->check () && $ this ->auth ->user ()->hasRole ($ roles [$ i ])) {
43
- return $ next ($ request );
44
- }
40
+ if ($ this ->auth ->check () && $ this ->auth ->user ()->hasRole (join (', ' , $ role ))) {
41
+ return $ next ($ request );
45
42
}
46
43
47
44
throw new RoleDeniedException ($ role );
You can’t perform that action at this time.
0 commit comments