2017-09-23 114 views
1

我使用laravel 5.5 *並安裝此https://github.com/artesaos/defender包的角色和權限,所有的東西工作正常,但是當我試圖獲得許可Laravel 5.5使用artesaos /後衛

$permissions = array_map(function ($permission) { 
     return $permission['name']; 
    }, $user->getAllPermissions()->toArray()); 

得到打擊錯誤:

"Symfony\Component\Debug\Exception\FatalThrowableError" file : H:\xampp\htdocs\LaraVueAdmin\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php" line: 147 message : "Type error: Argument 1 passed to Illuminate\Database\Eloquent\Model::__construct() must be of the type array, object given, called in H:\xampp\htdocs\LaraVueAdmin\vendor\artesaos\defender\src\Defender\Traits\Models\Permission.php on line 75"

+0

我通過更換https://github.com/artesaos/defender/blob/master/src/Defender/Traits/Models/Permission.php:75 找到溶液與 '返回PermissionUserPivot :: fromRawAttributes($ parent,$ attributes,$ table,$ exists,$ using);' –

回答

0

Muzafar阿里的這種解決方案,爲我工作:

我找到了解決辦法通過更換github.com/artesaos/defender/blob/master/src/Defender/Traits/…

return PermissionUserPivot::fromRawAttributes($parent, $attributes, $table, $exists, $using);

+0

這不提供問題的答案。一旦你有足夠的[聲譽](https://stackoverflow.com/help/whats-reputation),你將可以[對任何帖子發表評論](https://stackoverflow.com/help/privileges/comment);相反,[提供不需要提問者澄清的答案](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- I-DO-代替)。 - [來自評論](/ review/low-quality-posts/18683192) –