src/Traits/HasRoles.php
public function hasRole(Role $role)
    {
        $role = !is_string($role) ?: Role::where(['name' => $role])->firstOrFail();

        if ($role) {
            foreach ($this->roles as $r) {
                if ($r->id == $role->id) {
                    return true;
                }
            }
        }

        return false;
    }
public function hasRole(Role $role)
    {
        $role = !is_string($role) ?: Role::where(['name' => $role])->firstOrFail();

        if ($role) {
            foreach ($this->roles as $r) {
                if ($r->id == $role->id) {
                    return true;
                }
            }
        }

        return false;
    }
public function hasRole ( Role $ role ) { $ role = ! is_string ( $ role ) ? : Role :: where ( [ 'name' => $ role ] ) -> firstOrFail ( ) ; if ( $ role ) { foreach ( $ this -> roles as $ r ) { if ( $ r -> id == $ role -> id ) { return true ; } } } return false ; }
Returns true if the user has the role.

@param mixed $role

@return bool
Returns true if the user has the role .