Indatus\Ranger\ApiDatabase\QueryExecution\InstanceQuery::getInstance PHP Метод

getInstance() защищенный Метод

getInstance - The ApiQueryAssemblerInterface will build the query from any api parameters that were passed in. Eager loaded relations joins, and left joins will be appended to the query builder and returned by the buildQueryFromApiParams() method. The returned value will then call the first() method which will return an Eloquent model instance object.
protected getInstance ( ) : array
Результат array
    protected function getInstance()
    {
        //Using polymorphism to loop through the apiQueryBuilder objects
        //ie) Joins, LeftJoins, etc. and call buildQueryFromParameters()
        //on each of those objects
        foreach ($this->apiQueryBuilders as $queryBuilder) {
            $this->builder = $queryBuilder->buildQueryFromParameters($this->builder, $this->requestContainer->getInput());
        }
        $table = $this->requestContainer->getTable();
        //must run primary key after running handleApiParams because
        //any joins modifys the primaryKey to avoid ambiguity error
        $primaryKey = $table . '.' . $this->requestContainer->getPrimaryKey();
        $id = $this->requestContainer->getId();
        if ($this->isNestedResource()) {
            $instance = $this->_buildNestedResource($table, $primaryKey, $id);
        } else {
            $instance = $this->builder->where($primaryKey, '=', $id)->first();
        }
        if (!$instance) {
            throw new ModelNotFoundException();
        }
        return $instance;
    }