-
-
Notifications
You must be signed in to change notification settings - Fork 128
Q: Query parameter name customisation #32
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
1. Can I customise how vue-query-api generates URL and names parameters?Yes, you can name params and values as you wish // GET /posts?filter[my_fancy_status]=ACTIVE_ONE
let posts = await Post
.where('my_fancy_status', 'ACTIVE_ONE')
.get() 2. Can I customise how array parameters are encoded in the URL? For example here is filter by array which in your documentation says its send like this:According to You can also pass in an array of filters to the allowedFilters() method. // GET /users?filter[name]=john&filter[email]=gmail
$users = QueryBuilder::for(User::class)
->allowedFilters(['name', 'email'])
->get();
// $users will contain all users with "john" in their name AND "gmail" in their email address // GET /users?filter[name]=seb,freek
$users = QueryBuilder::for(User::class)
->allowedFilters('name')
->get();
// $users will contain all users that contain "seb" OR "freek" in their name |
@robsontenorio you didn't get my answer right for the point 1. I want to customise the filter in
i would like to have
|
@PrimozRome I'm sorry, but right now it is not possible, because is sticked to the convention |
@robsontenorio I think it would be an useful add-on, having some-kind of configuration possibility to rename default key names. Really not a big deal I guess. |
UPDATE:
Excellent package by-the-way!
|
For now, lets stick to default. If you can, please submit a PR. |
Now that is possible |
Maybe I have missed it somehow but reading trough your docs I haven't found that you can customise how the parameters are named when sent to the back-end. For example if not working with Spatie ORM package.
Here are my two questions.
vue-query-api
generates URL and names parameters? From your docsFor example if I would like that
filter[status]
is namedfilter_by[status]
for example.I wonder if it's possible to send like this:
//GET /posts?filter[status][]=ACTIVE&filter[status][]=ARCHIVED
Thank you.
The text was updated successfully, but these errors were encountered: