protected function getResults($single = false)
    {
        $customAttributes = call_user_func($this->model."::getAppendFields");

        // Laravel's $appends adds attributes always to the output. With this method,
        // we can specify which attributes are to be included
        $appends = [];

        $fields = $this->parser->getFields();

        foreach ($fields as $key => $field) {
            if (in_array($field, $customAttributes)) {
                $appends[] = $field;
                unset($fields[$key]);
            }
            else {
                // Add table name to  fields to prevent ambiguous column issues
                $fields[$key] = $this->table . "." . $field;
            }
        }

        $this->parser->setFields($fields);

        if (!$single) {
            /** @var Collection $results */
            $results = $this->query->select($fields)->get();
        }
        else {
            /** @var Collection $results */
            $results = $this->query->select($fields)->skip(0)->take(1)->get();

            if ($results->count() == 0) {
                throw new ResourceNotFoundException();
            }
        }

        foreach($results as $result) {
            $result->setAppends($appends);
        }

        $this->processAppends($results);

        $this->results = $results;

        return $results;
    }
protected function getResults($single = false)
    {
        $customAttributes = call_user_func($this->model."::getAppendFields");

        // Laravel's $appends adds attributes always to the output. With this method,
        // we can specify which attributes are to be included
        $appends = [];

        $fields = $this->parser->getFields();

        foreach ($fields as $key => $field) {
            if (in_array($field, $customAttributes)) {
                $appends[] = $field;
                unset($fields[$key]);
            }
            else {
                // Add table name to  fields to prevent ambiguous column issues
                $fields[$key] = $this->table . "." . $field;
            }
        }

        $this->parser->setFields($fields);

        if (!$single) {
            /** @var Collection $results */
            $results = $this->query->select($fields)->get();
        }
        else {
            /** @var Collection $results */
            $results = $this->query->select($fields)->skip(0)->take(1)->get();

            if ($results->count() == 0) {
                throw new ResourceNotFoundException();
            }
        }

        foreach($results as $result) {
            $result->setAppends($appends);
        }

        $this->processAppends($results);

        $this->results = $results;

        return $results;
    }
protected function getResults ( $ single = false ) { $ customAttributes = call_user_func ( $ this -> model . "::getAppendFields" ) ; // Laravel's $appends adds attributes always to the output. With this method, // we can specify which attributes are to be included $ appends = [ ] ; $ fields = $ this -> parser -> getFields ( ) ; foreach ( $ fields as $ key => $ field ) { if ( in_array ( $ field , $ customAttributes ) ) { $ appends [ ] = $ field ; unset ( $ fields [ $ key ] ) ; } else { // Add table name to  fields to prevent ambiguous column issues $ fields [ $ key ] = $ this -> table . "." . $ field ; } } $ this -> parser -> setFields ( $ fields ) ; if ( ! $ single ) { /** @var Collection $results */ $ results = $ this -> query -> select ( $ fields ) -> get ( ) ; } else { /** @var Collection $results */ $ results = $ this -> query -> select ( $ fields ) -> skip ( 0 ) -> take ( 1 ) -> get ( ) ; if ( $ results -> count ( ) == 0 ) { throw new ResourceNotFoundException ( ) ; } } foreach ( $ results as $ result ) { $ result -> setAppends ( $ appends ) ; } $ this -> processAppends ( $ results ) ; $ this -> results = $ results ; return $ results ; }
Runs query and fetches results

@param bool $single
@return Collection
@throws ResourceNotFoundException
Runs query and fetches results