{"action":"created","issue":{"url":"https://api.github.com/repos/Zizaco/entrust/issues/222","labels_url":"https://api.github.com/repos/Zizaco/entrust/issues/222/labels{/name}","comments_url":"https://api.github.com/repos/Zizaco/entrust/issues/222/comments","events_url":"https://api.github.com/repos/Zizaco/entrust/issues/222/events","html_url":"https://github.com/Zizaco/entrust/issues/222","id":50277782,"number":222,"title":"Add scope for getting all users with a specific role","user":{"login":"kasperhartwich","id":616231,"avatar_url":"https://avatars.githubusercontent.com/u/616231?v=3","gravatar_id":"","url":"https://api.github.com/users/kasperhartwich","html_url":"https://github.com/kasperhartwich","followers_url":"https://api.github.com/users/kasperhartwich/followers","following_url":"https://api.github.com/users/kasperhartwich/following{/other_user}","gists_url":"https://api.github.com/users/kasperhartwich/gists{/gist_id}","starred_url":"https://api.github.com/users/kasperhartwich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasperhartwich/subscriptions","organizations_url":"https://api.github.com/users/kasperhartwich/orgs","repos_url":"https://api.github.com/users/kasperhartwich/repos","events_url":"https://api.github.com/users/kasperhartwich/events{/privacy}","received_events_url":"https://api.github.com/users/kasperhartwich/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Zizaco/entrust/labels/Proposal:%20Accepted","name":"Proposal: Accepted","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2014-11-27T10:46:59Z","updated_at":"2015-05-12T23:50:49Z","closed_at":null,"body":"I think you should consider to include a scope that gives you all users with a specific role.\r\nLike this:\r\n```php\r\npublic function scopeIsRole($query, $role) {\r\n    return $query->whereHas(\r\n        'roles', function($query) use ($role){\r\n            $query->where('name', $role);\r\n        }\r\n    );\r\n}\r\n```\r\nSo you can call `Users::isRole('Administrator')->get();` or better, when you are getting all users from another model `Company::where('name', 'Corp Inc')->users->isRole('Administrator');`."},"comment":{"url":"https://api.github.com/repos/Zizaco/entrust/issues/comments/101461941","html_url":"https://github.com/Zizaco/entrust/issues/222#issuecomment-101461941","issue_url":"https://api.github.com/repos/Zizaco/entrust/issues/222","id":101461941,"user":{"login":"tannermccoleman","id":5466184,"avatar_url":"https://avatars.githubusercontent.com/u/5466184?v=3","gravatar_id":"","url":"https://api.github.com/users/tannermccoleman","html_url":"https://github.com/tannermccoleman","followers_url":"https://api.github.com/users/tannermccoleman/followers","following_url":"https://api.github.com/users/tannermccoleman/following{/other_user}","gists_url":"https://api.github.com/users/tannermccoleman/gists{/gist_id}","starred_url":"https://api.github.com/users/tannermccoleman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tannermccoleman/subscriptions","organizations_url":"https://api.github.com/users/tannermccoleman/orgs","repos_url":"https://api.github.com/users/tannermccoleman/repos","events_url":"https://api.github.com/users/tannermccoleman/events{/privacy}","received_events_url":"https://api.github.com/users/tannermccoleman/received_events","type":"User","site_admin":false},"created_at":"2015-05-12T23:50:49Z","updated_at":"2015-05-12T23:50:49Z","body":"Not really sure how to test model scopes, but I'll try to figure that out shortly."}}