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

[8.x] Add custom pagination information in resource #39600

Merged
merged 2 commits into from
Nov 22, 2021
Merged

[8.x] Add custom pagination information in resource #39600

merged 2 commits into from
Nov 22, 2021

Conversation

chuoke
Copy link
Contributor

@chuoke chuoke commented Nov 13, 2021

In our projects, there are many return formats. To return different custom paging information, customize all of the classes for resource classes in the project each time. I've found that simply adding this method to the src/Illuminate/Http/Resources/Json/PaginatedResourceResponse.php saves a lot of rework.

Look at the tests to understand the use cases.

Before, I always re-customize these classes:

    AnonymousResourceCollection.php
    JsonResource.php
    PaginatedResourceResponse.php
    ResourceCollection.php
    ResourceResponse.php

After this pull request, I can return different paging information just add paginationInformation method to the collection resource class or custom collection method of the resource class.


I have not found and do not know if there is a better and more convenient way, if there is, please tell me, thanks.

@GrahamCampbell GrahamCampbell changed the title add custom pagination information in resource [8.x] Add custom pagination information in resource Nov 14, 2021
@taylorotwell taylorotwell merged commit e9f05f1 into laravel:8.x Nov 22, 2021
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 this pull request may close these issues.

2 participants