{"action":"created","issue":{"url":"https://api.github.com/repos/spatie/laravel-permission/issues/250","repository_url":"https://api.github.com/repos/spatie/laravel-permission","labels_url":"https://api.github.com/repos/spatie/laravel-permission/issues/250/labels{/name}","comments_url":"https://api.github.com/repos/spatie/laravel-permission/issues/250/comments","events_url":"https://api.github.com/repos/spatie/laravel-permission/issues/250/events","html_url":"https://github.com/spatie/laravel-permission/issues/250","id":219375390,"node_id":"MDU6SXNzdWUyMTkzNzUzOTA=","number":250,"title":"$this->roles returns null when using @hasrole()","user":{"login":"benrasmusen","id":9834,"node_id":"MDQ6VXNlcjk4MzQ=","avatar_url":"https://avatars3.githubusercontent.com/u/9834?v=4","gravatar_id":"","url":"https://api.github.com/users/benrasmusen","html_url":"https://github.com/benrasmusen","followers_url":"https://api.github.com/users/benrasmusen/followers","following_url":"https://api.github.com/users/benrasmusen/following{/other_user}","gists_url":"https://api.github.com/users/benrasmusen/gists{/gist_id}","starred_url":"https://api.github.com/users/benrasmusen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benrasmusen/subscriptions","organizations_url":"https://api.github.com/users/benrasmusen/orgs","repos_url":"https://api.github.com/users/benrasmusen/repos","events_url":"https://api.github.com/users/benrasmusen/events{/privacy}","received_events_url":"https://api.github.com/users/benrasmusen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2017-04-04T20:37:51Z","updated_at":"2018-10-11T16:58:02Z","closed_at":"2017-04-10T15:53:20Z","author_association":"NONE","body":"I'm trying to use the `@hasrole()` directive in my blade template, but I'm getting the following error:\r\n\r\n```\r\nFatalErrorException in HasRoles.php line 131:\r\nCall to a member function contains() on null\r\nin HasRoles.php line 131\r\n```\r\n\r\nIf I dump `$this->roles` in `HasRoles::hasRole()` it return null, though the User is what I would expect and that object does have roles assigned to them (verified in the db, as well as via `Auth::user()->roles()->get()`).\r\n\r\nAm I using it wrong, or missing some integration?\r\n\r\nBlade template code:\r\n\r\n```\r\n@hasrole(['Admin'])\r\n          ...\r\n@endhasrole\r\n```\r\n\r\nUser model:\r\n\r\n```\r\n<?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Backpack\\CRUD\\CrudTrait;\r\nuse Spatie\\Permission\\Traits\\HasRoles;\r\nuse Illuminate\\Notifications\\Notifiable;\r\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\r\nuse Backpack\\Base\\app\\Notifications\\ResetPasswordNotification as ResetPasswordNotification;\r\n\r\nclass User extends Authenticatable\r\n{\r\n    use Notifiable;\r\n    use CrudTrait;\r\n    use HasRoles;\r\n...\r\n```\r\n\r\nCurrent setup:\r\n\r\n- Laravel Framework 5.4.17\r\n- spatie/laravel-permission 1.12.0\r\n\r\nNot sure if it's relevant but I'm using Backpack CRUD:\r\n- backpack/base 0.7.16\r\n- backpack/crud 3.2.7\r\n- backpack/generators 1.1.8\r\n- backpack/pagemanager 1.1.3\r\n- backpack/permissionmanager 2.1.15\r\n- backpack/settings 2.0.15"},"comment":{"url":"https://api.github.com/repos/spatie/laravel-permission/issues/comments/429034989","html_url":"https://github.com/spatie/laravel-permission/issues/250#issuecomment-429034989","issue_url":"https://api.github.com/repos/spatie/laravel-permission/issues/250","id":429034989,"node_id":"MDEyOklzc3VlQ29tbWVudDQyOTAzNDk4OQ==","user":{"login":"elhawy","id":16866695,"node_id":"MDQ6VXNlcjE2ODY2Njk1","avatar_url":"https://avatars3.githubusercontent.com/u/16866695?v=4","gravatar_id":"","url":"https://api.github.com/users/elhawy","html_url":"https://github.com/elhawy","followers_url":"https://api.github.com/users/elhawy/followers","following_url":"https://api.github.com/users/elhawy/following{/other_user}","gists_url":"https://api.github.com/users/elhawy/gists{/gist_id}","starred_url":"https://api.github.com/users/elhawy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elhawy/subscriptions","organizations_url":"https://api.github.com/users/elhawy/orgs","repos_url":"https://api.github.com/users/elhawy/repos","events_url":"https://api.github.com/users/elhawy/events{/privacy}","received_events_url":"https://api.github.com/users/elhawy/received_events","type":"User","site_admin":false},"created_at":"2018-10-11T16:58:02Z","updated_at":"2018-10-11T16:58:02Z","author_association":"NONE","body":"i have the same problem but can not remove this column now because re factor @AlexVanderbist and @freekmurze!"}}
{"actor":{"display_login":"elhawy"}}