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

Added ability to customize query parameter names #42

Merged
merged 1 commit into from
Feb 18, 2019

Conversation

suth
Copy link
Contributor

@suth suth commented Jan 20, 2019

A problem mentioned in #31, #32, and #9 is that there is no way to change the parameter names used. Some developers customize the parameter names in spatie/laravel-query-builder or (like me) use spatie/laravel-json-api-paginate to match the JSON API spec.

I've written a new test and made a small attempt at an implementation. It might not be the best way to do this but since you asked for a PR I figured this would be a good start to get the feature rolling.

The main change is that a model can extend the parameterNames() method to change the parameters like so:

  parameterNames () {
    return {
      include: 'include_custom',
      filter: 'filter_custom',
      sort: 'sort_custom',
      fields: 'fields_custom',
      append: 'append_custom',
      page: 'page_custom',
      limit: 'limit_custom'
    }
  }

@codecov
Copy link

codecov bot commented Jan 20, 2019

Codecov Report

Merging #42 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #42   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           4      4           
  Lines         233    237    +4     
  Branches       41     41           
=====================================
+ Hits          233    237    +4
Impacted Files Coverage Δ
src/Parser.js 100% <100%> (ø) ⬆️
src/Model.js 100% <100%> (ø) ⬆️
src/Builder.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ddd2896...bd3f627. Read the comment docs.

@robsontenorio
Copy link
Owner

Thanks, i will review it ASAP.

Can you update README with this new changes ?

@robsontenorio robsontenorio merged commit f31d84f into robsontenorio:master Feb 18, 2019
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