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

[6.x] Allow developer to preserve query parameters on paginated Api resources #30745

Merged
merged 6 commits into from Dec 5, 2019

Conversation

@deleugpn
Copy link
Contributor

deleugpn commented Dec 3, 2019

Reattempt at #30729 without static configuration.

Instead of statically configuring it once, the developer would have to call ->preserveQueryParameters() after instantiating the Resource Collection, but I still like the DX with this case.

class MyHandler
{
    public function __invoke(MyRepository $repository)
    {
        return MyResourceCollection::make($repository->paginate())->preserveQueryParameters();
    }
}
deleugpn added 2 commits Dec 3, 2019
@taylorotwell

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 4, 2019

Yeah this feels a lot better. Thanks.

@driesvints

This comment has been minimized.

Copy link
Member

driesvints commented Dec 5, 2019

Maybe rename the method to something less verbose? Thinking withUrl or something in the likes.

deleugpn and others added 3 commits Dec 5, 2019
Co-Authored-By: Dries Vints <dries.vints@gmail.com>
Co-Authored-By: Dries Vints <dries.vints@gmail.com>
Co-Authored-By: Dries Vints <dries.vints@gmail.com>
*
* @var bool
*/
protected $queryParameters;

This comment has been minimized.

Copy link
@Alymosul

Alymosul Dec 5, 2019

Contributor

Maybe shouldPreserveQueryParamters would be better and expressive.

@taylorotwell taylorotwell merged commit 43cf1db into laravel:6.x Dec 5, 2019
1 check passed
1 check passed
continuous-integration/styleci/pr The analysis has passed
Details
@taylorotwell

This comment has been minimized.

Copy link
Member

taylorotwell commented Dec 5, 2019

I tweaked this into two methods and did some renaming:

image

@deleugpn deleugpn deleted the deleugpn:append-query-parameters branch Dec 5, 2019
d8vjork added a commit to skore/laravel-json-api that referenced this pull request Jan 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.