Call the given local model scopes.

@param  array  $scopes
@return static|mixed
549838
public function scopes(array $scopes)
    {
        $builder = $this;

        foreach ($scopes as $scope => $parameters) {
            // If the scope key is an integer, then the scope was passed as the value and
            // the parameter list is empty, so we will format the scope name and these
            // parameters here. Then, we'll be ready to call the scope on the model.
            if (is_int($scope)) {
                [$scope, $parameters] = [$parameters, []];
            }

            // Next we'll pass the scope callback to the callScope method which will take
            // care of grouping the "wheres" properly so the logical order doesn't get
            // messed up when adding scopes. Then we'll return back out the builder.
            $builder = $builder->callScope(
                [$this->model, 'scope'.ucfirst($scope)],
                (array) $parameters
            );
        }

        return $builder;
    }
730042
public function validateScopes($scopes, $redirectUri = null)
    {
        if (!\is_array($scopes)) {
            $scopes = $this->convertScopesQueryStringToArray($scopes);
        }

        $validScopes = [];

        foreach ($scopes as $scopeItem) {
            $scope = $this->scopeRepository->getScopeEntityByIdentifier($scopeItem);

            if ($scope instanceof ScopeEntityInterface === false) {
                throw OAuthServerException::invalidScope($scopeItem, $redirectUri);
            }

            $validScopes[] = $scope;
        }

        return $validScopes;
    }
710553
private function formatScopes(array $scopes)
    {
        if (empty($scopes)) {
            return [null]; //use at least 1 null scope
        }

        array_walk(
            $scopes,
            function (&$scope) {
                if (is_array($scope)) {
                    $scope = implode(' ', $scope);
                }
            }
        );

        return $scopes;
    }
368588
public function push($scope)
    {
        if (! is_array($scope)) {
            $scope = func_get_args();
        }

        $this->scopes[] = $scope;

        return $this;
    }
433281
protected function getOwnScopes()/*# : array */
    {
        // result
        $result = [];

        // all types avaible
        $allTypes = $this->getAllTypes(static::getScopes());

        // loop thru own scopes
        foreach ($this->scopes as $scope) {
            $result[$scope] = true;
            $this->matchParentType($scope, $allTypes, $result);
        }

        // alway add global scope
        $result[''] = true;

        return array_keys($result);
    }
118555
public function applyScopes()
    {
        if (! $this->scopes) {
            return $this;
        }

        $builder = $this;

        foreach ($builder->scopes as $identifier => $scope) {
            if (! isset($builder->scopes[$identifier])) {
                continue;
            }

            $builder->callScope(function (DynamoDbQueryBuilder $builder) use ($scope) {
                // If the scope is a Closure we will just go ahead and call the scope with the
                // builder instance. The "callScope" method will properly group the clauses
                // that are added to this query so "where" clauses maintain proper logic.
                if ($scope instanceof Closure) {
                    $scope($builder);
                }

                // If the scope is a scope object, we will call the apply method on this scope
                // passing in the builder and the model instance. After we run all of these
                // scopes we will return back the builder instance to the outside caller.
                if ($scope instanceof Scope) {
                    throw new NotSupportedException('Scope object is not yet supported');
                }
            });

            $builder->withoutGlobalScope($identifier);
        }

        return $builder;
    }
974544
protected function clientGetScope(array $parameters): ?array
    {
        $scope = $this->clientReadStringValue($parameters, 'scope');

        return empty($scope) === false ? explode(' ', $scope) : null;
    }
360921
protected function getAllTypes(array $scopes)/*# : array */
    {
        $result = [];
        foreach ($scopes as $scope) {
            if ($this->isAType($scope)) {
                $result[] = $scope;
            }
        }
        return $result;
    }
566674
public function scope(Scope $scope)
    {
        $callable = $scope->getQuery();

        if (is_string($callable)) {
            /*
             * Adds a Class "ClassName::class" syntax.
             *
             * @note In this case Query class should implement Contracts\Module\Queryable interface.
             * @example: (new Scope('name'))->setQuery(Queryable::class);
             */
            if (class_exists($callable)) {
                $object = app($callable);

                if (!method_exists($object, 'query')) {
                    throw new \Terranet\Administrator\Exception(
                        sprintf(
                            'Query object %s should implement %s interface',
                            get_class($object),
                            \Terranet\Administrator\Contracts\Module\Queryable::class
                        )
                    );
                }

                $this->query = $object->query($this->query);

                return $this;
            }

            /*
             * Allows "SomeClass@method" syntax.
             *
             * @example: (new Scope('name'))->addQuery("User@active")
             */
            if (str_contains($callable, '@')) {
                list($object, $method) = explode('@', $callable);

                $this->query = app($object)->$method($this->query);

                return $this;
            }
        }

        /*
         * Allows adding a \Closure as a query;
         *
         * @example: (new Scope('name'))->setQuery(function($query) { return $this->modify(); })
         */
        if ($callable instanceof Closure) {
            $this->query = $callable($this->query);

            return $this;
        }

        /*
         * Accepts callable builder
         *
         * @example: (new Scope('name'))->setQuery([SomeClass::class, "queryMethod"]);
         */
        if (is_callable($callable)) {
            list($object, $method) = $callable;

            if (is_string($object)) {
                $object = app($object);
            }

            // Call Model Scope immediately when detected.
            //
            // @note: We don't use call_user_func_array() here
            // because of missing columns in returned query.
            $this->query = with(
                $this->model->is($object) ? $this->query : $object
            )->{$method}($this->query);
        }

        return $this;
    }
574323
public function set($scopes)
    {
        $this->scopes = func_get_args();

        if (is_array($scopes)) {
            $this->scopes[] = $scopes;
        }

        return $this->getDisplay();
    }
819537
public static Scopes from(String... scopes)
    {
        if (scopes == null || scopes.length == 0) return NONE;
        return new Scopes(scopes, true);
    }
1331731
protected function convertToTerLocales(array $locales) {
		$terLocales = array();
		foreach ($locales as $locale) {
			$terLocales[] = isset($this->isoReverseMapping[$locale]) ? $this->isoReverseMapping[$locale] : $locale;
		}
		return $terLocales;
	}
123964
protected function refreshGetScope(array $parameters): ?array
    {
        $scope = $this->refreshReadStringValue($parameters, 'scope');

        return empty($scope) === false ? explode(' ', $scope) : null;
    }
266001
public function call(...$params)
    {
        $params = $params ?: $this->params;
        if(!$this->instanciated) {
            $this->instanciate();
        }

        return call_user_func_array($this->callable, $params);
    }
230603
public function getAuthorizationUrl($scopes = [])
    {
        $this->provider;
        $authorizationUrl = $this->provider->getAuthorizationUrl([
            'scope' => join(' ', $scopes)
        ]);
        $_SESSION['oauth2_lockme_state'] = $this->provider->getState();
        return $authorizationUrl;
    }
965157
public function scope(string $scope, ...$arguments)
	{
		$this->model->{Str::underscored2camel($scope) . 'Scope'}(...array_merge([$this], $arguments));

		return $this;
	}
206308
protected function normalizeScopeArray(array $scopes, $parentKey = 'list.scopes')
    {
        $scopes = $this->normalizeStandardArrayProperty(
            $scopes,
            'strategy',
            ModelScopeData::class,
            $parentKey
        );

        // Make sure that each scope entry has at least a method or a strategy
        foreach ($scopes as $key => &$value) {
            if ( ! $value['method'] && ! $value['strategy']) {
                $value['method'] = $key;
            }
        }

        unset($value);

        return $scopes;
    }