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

[Feature Request] Eloquent Api Resource Pagination #641

Closed
zek opened this issue Nov 8, 2019 · 7 comments
Closed

[Feature Request] Eloquent Api Resource Pagination #641

zek opened this issue Nov 8, 2019 · 7 comments
Labels
next Relevant for the next major release

Comments

@zek
Copy link
Contributor

zek commented Nov 8, 2019

We should also support pagination for api resources

https://laravel.com/docs/master/eloquent-resources#pagination

Should we add another annotation like @apiResourcePagination

There are 2 methods for pagination ( https://laravel.com/docs/5.8/pagination )

simple and default

So
@apiResourcePaginate resolves to Model::paginate(15);
@apiResourcePaginate simple resolves to Model::simplePaginate(15);

What do you guys think about?

@zek zek changed the title Eloquent Api Resource Pagination [Feature Request] Eloquent Api Resource Pagination Nov 8, 2019
@robbieaverill
Copy link
Contributor

The same could be said for @transformerCollection with @transformerModel, if you were to use code like this in your controller:

$transformer = new Collection($categories, new CategoryTransformer(), 'data');
$transformer->setPaginator(new IlluminatePaginatorAdapter($categories));

return $fractal->createData($tranformer)->toArray();

The response should be similar to {"data": [ {category}, {category} ], "meta": ...}, but there's no way to configure pagination rules for Fractal transformers right now.

@exzachlyvv
Copy link

+1

@shalvah shalvah added the next Relevant for the next major release label May 2, 2020
@shalvah
Copy link
Contributor

shalvah commented May 7, 2020

This is now supported in Scribe 🙂.

@shalvah shalvah closed this as completed May 7, 2020
@shalvah
Copy link
Contributor

shalvah commented May 13, 2020

@mehrancodes
Copy link

@shalvah could you please update the new documentation for this paginate feature? thanks!

@shalvah
Copy link
Contributor

shalvah commented Aug 28, 2020

@mehrancodes Read the last few comments.

@shalvah
Copy link
Contributor

shalvah commented Aug 28, 2020

Whoops, I see those links are broken. You can just go to scribe.rtfd.io and search for "API Resources".

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

No branches or pull requests

5 participants