Returns whether the current user has the given permission(s).

@param string|string $permission
@param bool            $allowAny     if true, allows if any is permitted
@return bool
432029
public function can($permission, $allowAny = false)
    {
        if ( ! ($user = $this->user())) {
            return false;
        }

        if ($user->isAdmin()) {
            return true;
        }

        return $user->can($permission, $allowAny);
    }
720279
public function can($permission, $requireAll = false)
    {
        if ($this->cachedRoles()->where('name', 'admin')->count()) {
            return true;
        }

        return $this->entrustCan($permission, $requireAll = false);
    }
245795
public function hasPermissions($permissions)
    {
        if ($this->user() === null) {
            return null;
        }

        if (!is_array($permissions)) {
            $permissions = func_get_args();
        }

        // Count permissions because user need user to have all permissions passed as parameter
        return count(array_intersect($permissions, $this->permissions)) === count($permissions);
    }
776826
public function can($permission, $requireAll = false)
    {
        if ($user = $this->user()) {
            return $user->can($permission, $requireAll);
        }

        return false;
    }
270856
public function checkPermission($permission)
    {
        $roleAttribute = "can_{$permission}";
        return isset($this->$roleAttribute) ? (bool)$this->$roleAttribute : false;
    }
910423
public function hasPermission($permission)
    {
        $perm_id = $this->getPermissionId($permission);
        $roles = $this->getRolesWithPermission($perm_id);

        foreach ($roles as $role)
            if ($this->hasRole($role))
                return true;

        return false;
    }
142771
public function currentRoleHasPermission($permission, $requireAll = false)
    {
        if (is_array($permission)) {
            if (empty($permission)) {
                return true;
            }

            foreach ($permission as $permissionName) {
                $hasPermission = $this->currentRoleHasPermission($permissionName);

                if ($hasPermission && !$requireAll) {
                    return true;
                } elseif (!$hasPermission && $requireAll) {
                    return false;
                }
            }

            // If we've made it this far and $requireAll is FALSE, then NONE of the permissions were found.
            // If we've made it this far and $requireAll is TRUE, then ALL of the permissions were found.
            // Return the value of $requireAll.
            return $requireAll;
        }

        foreach ($this->currentRoleCachedPermissions() as $perm) {
            if (str_is($permission, $perm['name'])) {
                return true;
            }
        }

        return false;
    }
1157181
public function attachPermission($permission, $granted = true)
    {
        if($granted)
            return (!$this->grantedPermissions()->get()->contains($permission)) ? $this->userPermissions()->attach($permission, array('granted' => TRUE)) : true;
        else
            return (!$this->deniedPermissions()->get()->contains($permission)) ? $this->userPermissions()->attach($permission, array('granted' => FALSE)) : true;

    }
794269
public function canById(int $permissionId): bool
    {
        if (isset($this->permission[$permissionId])) {
            return true;
        }

        return false;
    }
254852
public function hasPermission($permission, $all = false)
    {
        if ($this->isPretendEnabled()) {
            return $this->pretend('hasPermission');
        }

        if (!$all) {
            return $this->hasOnePermission($permission);
        }

        return $this->hasAllPermissions($permission);
    }
703593
public function hasDirectPermission($permission): bool
    {
        if (is_string($permission)) {
            $permission = PermissionProxy::findByName($permission, $this->getDefaultGuardName());

            if (! $permission) {
                return false;
            }
        }

        return $this->permissions->contains('id', $permission->id);
    }
71104
public function can($permission)
    {
        $permissions = $this->getPermissions();

        if (is_array($permission)) {
            $permissionCount   = count($permission);
            $intersection      = array_intersect($permissions, $permission);
            $intersectionCount = count($intersection);

            return ($permissionCount == $intersectionCount) ? true : false;
        } else {
            return in_array($permission, $permissions);
        }
    }
531218
public function hasPermission($recipient, $permission)
    {

        if ($recipient instanceof Group) {
            $check = true;
            foreach ($recipient->getLogins() as $login) {
                if ($this->hasLoginPermission($login, $permission) === false) {
                    $check = false;
                }
            }

            return $check;
        } else {
            return $this->hasLoginPermission($recipient, $permission);
        }
    }
731251
function is_permission_requested( $permission ) {
            return isset( $this->_permissions[ $permission ] ) && ( true === $this->_permissions[ $permission ] );
        }
1327108
public function findWithPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($role) use ($permission) {
                return $role->has($permission);
            }
        );
    }
142494
public function hasPermission($permission)
    {
        if ($this->isAdmin()) {
            return true;
        }

        if (is_null($this->permissions)) {
            $this->permissions = $this->getPermissions();
        }

        return in_array($permission, $this->permissions);
    }
9360
protected function hasFilter($permission)
    {
        if ($this->cacheHas($permission)
            && true === $this->cache($permission)
        ) {
            return true;
        }

        $permissionResult   =   $this->getPermission($permission);

        if ($permissionResult) {
            return $this->cache($permission, $permissionResult->isAllowed());
        }

        return $this->cache($permission, false);
    }