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

add ability to acess only the query params or the actual route params #744

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

peter-emad99
Copy link
Contributor

Added two new methods to Router

route().queryParams to get only the query paramters parsed with the qs
route().routeParams to get only the actual route params without query params

i didn't like the routeParams name as it's no clear enough but i couldn't find another name

this complete #742

i didn't update the docs to inlude this but if approved will do that

@bakerkretzmar bakerkretzmar self-assigned this Apr 10, 2024
@bakerkretzmar
Copy link
Collaborator

What's your use case for this? Are you primarily interested in the route params or the query params?

I'm on the fence about this, because there are other ways to get most of this info already, like with URLSearchParams, and because Laravel's route() helper doesn't do this directly.

@peter-emad99
Copy link
Contributor Author

as i mentioned in the issue ... using UrlSearchParams don't parse the params the same way when using the route() function because of it using qs under the hood ..
i have some cases i wanted to access only the route params or the query params

when there is a route parameter and query parameter with the same name ..and you want to access only the query or route... with route().params the one from the query will always overwrite the route params {...params,...query}

it gives more control to apply filters and search and apply reset with something like this
router.reload(route(route.().current(),route().routeParams)) or
router.reload(route(route.().current(),{...route().params,...filterData})) ,

yes we can achieve the same thing with some little js but why when we have a better and easy way using route() herlper ?

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.

None yet

2 participants