laravel-responder icon indicating copy to clipboard operation
laravel-responder copied to clipboard

Filtering from query string - opposite to only

Open Hesesses opened this issue 5 years ago • 2 comments

Filtering From Query String

Fields will automatically be filtered if the filter_fields_parameter configuration key is set to a string. It defaults to only, allowing you to filter fields from the query string:

GET /products?only=id,name

Would be nice if you could have the opposite for only, for example: ...?hide=id,name ...?except=id,name

And then those fields would be empty when returning the transformer

Hesesses avatar Mar 04 '20 12:03 Hesesses

Agreed that would be nice, however, if I remember correctly Fractal didn't have this feature and the filtering is currently based on their implementation. With that said I started out adding both only and except to the new version, but then removed them as I didn't want the package to be concerned about the query string anymore. Instead I was looking into moving all this logic into a new Laravel Requester or Laravel Inquirer package which handled the parsing of query strings and allowed for filtering fields, querying results, sorting, including relations etc.

Was thinking of creating an issue to discuss this idea further, but would love to hear your initial opinions on it.

flugg avatar Mar 06 '20 15:03 flugg

I always like when things can be splitted to smaller components and if all this logic can be moved to Requester or Inquirer packages, that sounds good if those packages are flexible to work with :)

Hesesses avatar May 22 '20 05:05 Hesesses