Skip to content
Discussion options

You must be logged in to vote

I have successfully overridden the HasPermissions trait in the user model using the following code, and it is currently functioning as intended. However, I would like to know if there is a better way to achieve this.

public function getAllPermissions(): Collection
    {
  
       $permissions = $this->permissions; // replaced by below line
        $permissions = collect();
       if (method_exists($this, 'roles')) {
            $permissions = $permissions->merge($this->getPermissionsViaRoles());
        }

        return $permissions->sort()->values();
    }

    public function hasDirectPermission($permission): bool
    {
        return false;
    }

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@drbyte
Comment options

drbyte Mar 22, 2023
Collaborator

@emmanuelsoto22
Comment options

@drbyte
Comment options

drbyte May 23, 2024
Collaborator

Answer selected by drbyte
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants