Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merging of role and user permissions does not work without permission id #37

Open
aduscher opened this issue Jun 20, 2018 · 0 comments
Open

Comments

@aduscher
Copy link

aduscher commented Jun 20, 2018

When using both role permissions & user permissions the following problem occurs:

The Eloquent statement in Litepie\Roles\Traits\HasRoleAndPermission::rolePermissions() does not include the permission id. So when the merge of the two permissions sets is done in function getPermissions(), the role permissions are ignored because no key attribute is available in the hydrated Permission object.

In class Litepie\Roles\Traits\HasRoleAndPermission the function rolePermissions() can be updated accordingly to fix the issue:

public function rolePermissions()
{
   ...
return $permissionModel::select(['permissions.id', 'permissions.slug', 'permission_role.created_at as pivot_created_at', 'permission_role.updated_at as pivot_updated_at'])
					->join('permission_role', 'permission_role.permission_id', '=', 'permissions.id')
					->join('roles', 'roles.id', '=', 'permission_role.role_id')
					->whereIn('roles.id', $this->getRoles()->pluck('id')->toArray())
					->orWhere('roles.level', '<', $this->level())
					->groupBy(['permissions.id', 'permissions.slug', 'pivot_created_at', 'pivot_updated_at']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant