roles icon indicating copy to clipboard operation
roles copied to clipboard

hasRole and permission works with $key not $value

Open alamallam opened this issue 7 years ago • 1 comments

alamallam avatar Sep 22 '17 18:09 alamallam

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); }); }

junezzao avatar Feb 08 '18 04:02 junezzao