laravel-acl icon indicating copy to clipboard operation
laravel-acl copied to clipboard

Resolve permissions inheritance based on roles issue

Open QuentinPetel opened this issue 9 years ago • 4 comments
trafficstars

See https://github.com/kodeine/laravel-acl/issues/168

QuentinPetel avatar Nov 15 '16 18:11 QuentinPetel

If you're using the laravel cache, do php artisan cache:clear to have it work. Edit: Cache::forget() added when assign/revoke Role/Permission

QuentinPetel avatar Nov 16 '16 15:11 QuentinPetel

@QuentinPetel can you please resolve the conflicts so i can merge this?

Thanks

kodeine avatar Dec 08 '16 00:12 kodeine

Done.

One thing however still not fixed. If you already have an $user loaded, you have to ::find this user again to avoid getting roles or permissions outdated.

Something like : $user->assignRole('slug_role'); $user = User::find($user->id);

QuentinPetel avatar Dec 08 '16 01:12 QuentinPetel

Something like : $user->assignRole('slug_role'); $user = User::find($user->id);

Just a few days ago a refresh method has been added to Model (bot not yet released). So you could use $this->refresh(); within assignRole now. For older versions you could implement the refresh yourself.

if (version_compare(App::version(), '5.4.24', '>=')) { // Version number is a guess
    $this->refresh();
} else {
    if (! $this->exists) {
        return;
    }
    $this->load(array_keys($this->relations));
    $this->setRawAttributes(static::findOrFail($this->getKey())->attributes);
}

pimlie avatar May 18 '17 10:05 pimlie