Skip to content
This repository has been archived by the owner on Mar 18, 2022. It is now read-only.

hasRole and permission works with $key not $value #216

Open
alamallam opened this issue Sep 22, 2017 · 1 comment
Open

hasRole and permission works with $key not $value #216

alamallam opened this issue Sep 22, 2017 · 1 comment

Comments

@alamallam
Copy link

No description provided.

@junezzao
Copy link

junezzao commented Feb 8, 2018

Override hasRole() in User model if using Laravel >= 5.3

/**

  • Check if the user has role.
  • @param int|string $role
  • @return bool
    */
    public function hasRole($role)
    {
    return $this->getRoles()->contains(function ($value, $key) use ($role) {
    return $role == $value->id || Str::is($role, $value->slug);
    });
    }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants