{"action":"created","issue":{"url":"https://api.github.com/repos/Zizaco/entrust/issues/214","labels_url":"https://api.github.com/repos/Zizaco/entrust/issues/214/labels{/name}","comments_url":"https://api.github.com/repos/Zizaco/entrust/issues/214/comments","events_url":"https://api.github.com/repos/Zizaco/entrust/issues/214/events","html_url":"https://github.com/Zizaco/entrust/issues/214","id":48090682,"number":214,"title":"Laravel 5: Class 'App\\Permission' not found","user":{"login":"JoolsMcFly","id":4972399,"avatar_url":"https://avatars.githubusercontent.com/u/4972399?v=3","gravatar_id":"","url":"https://api.github.com/users/JoolsMcFly","html_url":"https://github.com/JoolsMcFly","followers_url":"https://api.github.com/users/JoolsMcFly/followers","following_url":"https://api.github.com/users/JoolsMcFly/following{/other_user}","gists_url":"https://api.github.com/users/JoolsMcFly/gists{/gist_id}","starred_url":"https://api.github.com/users/JoolsMcFly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoolsMcFly/subscriptions","organizations_url":"https://api.github.com/users/JoolsMcFly/orgs","repos_url":"https://api.github.com/users/JoolsMcFly/repos","events_url":"https://api.github.com/users/JoolsMcFly/events{/privacy}","received_events_url":"https://api.github.com/users/JoolsMcFly/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-11-07T15:04:02Z","updated_at":"2015-02-11T16:54:54Z","closed_at":"2015-02-11T16:54:54Z","body":"Hey guys,\r\n\r\nI am having issues using Entrust with Laravel 5.\r\n\r\nFor the sake of simplicity here's the simplest code snippet to repro my issue..\r\n```php\r\n//HomeController.php\r\n    if ( \\Auth::user()->can(VIEW_ACCOUNTS_PERMISSION)) {\r\n      die(\"OK\");\r\n    }\r\n    else {\r\n      die(\"KO\");\r\n    }\r\n```\r\n\r\nRunning above code I get:\r\nClass 'App\\Permission' not found\r\n\r\nI traced things down with xdebug and error happens in Entrust/HasRole.php:\r\n```php\r\n            // Validate against the Permission table\r\n            foreach ($role->perms as $perm) { // here!\r\n                if ($perm->name == $permission) {\r\n                    return true;\r\n                }\r\n            }\r\n```\r\n\r\nwhich calls\r\n```php\r\n    /**\r\n     * Many-to-Many relations with Permission named perms as permissions is already taken.\r\n     *\r\n     * @return void\r\n     */\r\n    public function perms()\r\n    {\r\n        // To maintain backwards compatibility we'll catch the exception if the Permission table doesn't exist.\r\n        // TODO remove in a future version.\r\n        try {\r\n\t\treturn $this->belongsToMany($this->getAppNamespace().Config::get('entrust::permission'), Config::get('entrust::permission_role_table'));\r\n        } catch (Exception $e) {\r\n            // do nothing\r\n        }\r\n    }\r\n```\r\n\r\nThe issue seems to be with AppNamespaceDetectorTrait::getAppNamespace which returns App\\ so belongsToMany tries to load App\\Permission.php instead of App\\models\\Permission.php\r\n\r\nHere's my composer PSR4 definition:\r\n```json\r\n//composer.json\r\n\t\t\"psr-4\": {\r\n\t\t\t\"App\\\\\": \"app/\",\r\n\t\t\t\"MyCompany\\\\\": \"app/MyCompany\"\r\n\t\t}\r\n```\r\n\r\nAny idea?"},"comment":{"url":"https://api.github.com/repos/Zizaco/entrust/issues/comments/73917370","html_url":"https://github.com/Zizaco/entrust/issues/214#issuecomment-73917370","issue_url":"https://api.github.com/repos/Zizaco/entrust/issues/214","id":73917370,"user":{"login":"JoolsMcFly","id":4972399,"avatar_url":"https://avatars.githubusercontent.com/u/4972399?v=3","gravatar_id":"","url":"https://api.github.com/users/JoolsMcFly","html_url":"https://github.com/JoolsMcFly","followers_url":"https://api.github.com/users/JoolsMcFly/followers","following_url":"https://api.github.com/users/JoolsMcFly/following{/other_user}","gists_url":"https://api.github.com/users/JoolsMcFly/gists{/gist_id}","starred_url":"https://api.github.com/users/JoolsMcFly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoolsMcFly/subscriptions","organizations_url":"https://api.github.com/users/JoolsMcFly/orgs","repos_url":"https://api.github.com/users/JoolsMcFly/repos","events_url":"https://api.github.com/users/JoolsMcFly/events{/privacy}","received_events_url":"https://api.github.com/users/JoolsMcFly/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T16:54:54Z","updated_at":"2015-02-11T16:54:54Z","body":"Hey guys,\r\n\r\nsorry I didn't get back to you earlier.\r\nAdding namespaces didn't fix it but now L5 is out everything works as expected.\r\n\r\nThanks."}}