app\Models\Access\User\Traits\UserAccess::allowMultiple PHP Method

allowMultiple() public method

Check an array of permissions and whether or not all are required to continue
public allowMultiple ( $permissions, $needsAll = false ) : boolean
$permissions
$needsAll
return boolean
    public function allowMultiple($permissions, $needsAll = false)
    {
        //If not an array, make a one item array
        if (!is_array($permissions)) {
            $permissions = array($permissions);
        }
        //User has to possess all of the permissions specified
        if ($needsAll) {
            $hasPermissions = 0;
            $numPermissions = count($permissions);
            foreach ($permissions as $perm) {
                if ($this->allow($perm)) {
                    $hasPermissions++;
                }
            }
            return $numPermissions == $hasPermissions;
        }
        //User has to possess one of the permissions specified
        foreach ($permissions as $perm) {
            if ($this->allow($perm)) {
                return true;
            }
        }
        return false;
    }