Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limiting results with presenter switched on #726

Closed
vetuk opened this issue Aug 26, 2020 · 0 comments · Fixed by #754
Closed

Limiting results with presenter switched on #726

vetuk opened this issue Aug 26, 2020 · 0 comments · Fixed by #754

Comments

@vetuk
Copy link

vetuk commented Aug 26, 2020

If we turn on presenter & transformer for a repository and call limit() on the instance it returns an error because the limit() method in BaseRepository calls parserResult() and if you have presenter on then it will call the transform method which expects an instance of the model but instead it is getting the model which is a query builder.

If I change the code for limit to the following (so it is similar to orderBy()):

public function limit($limit)
    {
        $this->model = $this->model->limit($limit);

        return $this;
}

It all works as it should with the presenter.

public function limit($limit)
    {
        $this->applyCriteria();
        $this->applyScope();

        $results = $this->model->limit($limit);

        $this->resetModel();

        return $this->parserResult($results);
}

The above code which is currently in Eloquent\BaseRepository expects model->limit($limit) to return results but limit in eloquent model doesn't work that way.

I would make a pull request but I am not sure how to do it on github.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant