{"action":"opened","issue":{"url":"https://api.github.com/repos/spatie/laravel-permission/issues/117","repository_url":"https://api.github.com/repos/spatie/laravel-permission","labels_url":"https://api.github.com/repos/spatie/laravel-permission/issues/117/labels{/name}","comments_url":"https://api.github.com/repos/spatie/laravel-permission/issues/117/comments","events_url":"https://api.github.com/repos/spatie/laravel-permission/issues/117/events","html_url":"https://github.com/spatie/laravel-permission/issues/117","id":174008433,"number":117,"title":"Middleware multiple roles","user":{"login":"warlord0","id":9975039,"avatar_url":"https://avatars.githubusercontent.com/u/9975039?v=3","gravatar_id":"","url":"https://api.github.com/users/warlord0","html_url":"https://github.com/warlord0","followers_url":"https://api.github.com/users/warlord0/followers","following_url":"https://api.github.com/users/warlord0/following{/other_user}","gists_url":"https://api.github.com/users/warlord0/gists{/gist_id}","starred_url":"https://api.github.com/users/warlord0/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/warlord0/subscriptions","organizations_url":"https://api.github.com/users/warlord0/orgs","repos_url":"https://api.github.com/users/warlord0/repos","events_url":"https://api.github.com/users/warlord0/events{/privacy}","received_events_url":"https://api.github.com/users/warlord0/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-30T12:40:58Z","updated_at":"2016-08-30T12:40:58Z","closed_at":null,"body":"Is it possible to use multiple roles in middleware?\r\n\r\neg. I have 3 roles setup.\r\nTask User\r\nTask Owner\r\nTask Manager\r\n\r\nThe user can view\r\nThe owner can update their own\r\nThe manager can update anyones\r\n\r\nSo on the form view route I need to check they have any of these roles.\r\nOn the form update view I need to make sure they have Owner or Manager roles.\r\n\r\nThis is what I have so far. I've made the permission optional.\r\n```php\r\nRoute::group(['prefix' => 'task', 'middleware' => ['role:Task User']], function() {\r\n...\r\n```\r\nBut then I have to make a Task Manager also a Task User to view the tasks.\r\n\r\nI think I know why this doesn't work. But can't figure out the \"or\" part.\r\n```php\r\nRoute::group(['prefix' => 'task', 'middleware' => ['role:Task User','role:Task Owner','role:Task Manager']], function() {\r\n...\r\n```\r\n\r\n```php\r\n    public function handle($request, Closure $next, $role, $permission = null)\r\n    {\r\n        \r\n        if (Auth::guest()) {\r\n            return redirect('/');\r\n        }\r\n\r\n        if (! $request->user()->hasAnyRole($role))\r\n        {\r\n              abort(403);\r\n        }        \r\n\r\n        \r\n        if ($permission != null && ! $request->user()->can($permission)) {\r\n            abort(403);\r\n        }\r\n        \r\n        \r\n        return $next($request);\r\n    }\r\n```"}}
{"actor":{"display_login":"warlord0"}}