spatie / laravel-permission

Associate users with roles and permissions
https://spatie.be/docs/laravel-permission
MIT License
12.18k stars 1.78k forks source link

Will it support Laravel Spark 5.0 ? #640

Closed youyi1314 closed 6 years ago

youyi1314 commented 6 years ago

I using Laravel Spark 5.0.1, Laravel 5.5, and now i add this package. when i use tinker command below, it show error on Undefined index: provider in /home/vhost/mcal/vendor/spatie/laravel-permission/src/Guard.php on line 33

return config("auth.providers.{$guard['provider']}.model");

before using tinker i created admin role using artisan php artisan permission:create-role admin web

Tinker

$user = App\User::find(1); => App\User { _UserDATA} $user->assignRole('admin');

drbyte commented 6 years ago

This issue is resolved with v2.8.1

youyi1314 commented 6 years ago

Thanks @drbyte

Naoray commented 6 years ago

@drbyte in v2.9.1 the error is still occurring

Your changes aren't in the release => https://github.com/spatie/laravel-permission/blob/2.9.1/src/helpers.php#L10-L13

Do you want to add this PR or should I?

Thanks,

Barrykilby commented 6 years ago

@drbyte I have had just had the same problem but getting triggered by helpers.php when Spark is installed with Nova and attempting to use https://novapackages.com/packages/vyuldashev/nova-permission to manage things. Below seems to solve it.

function getModelForGuard(string $guard) { return collect(config('auth.guards')) ->map(function ($guard) { if (! isset($guard['provider'])) { return; } return config("auth.providers.{$guard['provider']}.model"); })->get($guard); }