-
Notifications
You must be signed in to change notification settings - Fork 107
Pagination in readRelatedResource #22
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
Comments
I would gladly help out and update the functionality |
Hi! Yes, I need to do some work on the related resources stuff so it is all taken care off out of the box, but haven't got round to that yet. In the meantime the following should work if you're on the $paging = app(CloudCreativity\JsonApi\Contracts\Pagination\PaginatorInterface::class);
$page = app(CloudCreativity\LaravelJsonApi\Pagination\Page::class);
/** If the client has requested a page... */
if ($paging->getCurrentPage()) {
$data = $model->{$key}()->paginate($paging->getPerPage());
} /** Client has not request a page */
else {
$data = $model->{$key};
}
$page->setData($data);
return $this->reply()->content($page); Let me know how you get on and obviously I can help more if you're still stuck. I'll probably be able to land proper related resource handling in |
Actually, slight correction. The page object will only accept a Laravel paginator in its $paging = app(CloudCreativity\JsonApi\Contracts\Pagination\PaginatorInterface::class);
$page = app(CloudCreativity\LaravelJsonApi\Pagination\Page::class);
/** If the client has requested a page... */
if ($paging->getCurrentPage()) {
$data = $model->{$key}()->paginate($paging->getPerPage());
$data = $page->setData($data);
} /** Client has not request a page */
else {
$data = $model->{$key};
}
return $this->reply()->content($data); |
On the 1.0 dev branch you can now paginate related resources. |
Uh oh!
There was an error while loading. Please reload this page.
I can't figure out an way of doing pagination of a related resource.
The text was updated successfully, but these errors were encountered: