selahattinunlu / laravel-api-query-builder

Laravel & Lumen Api Query Builder Package
332 stars 66 forks source link

Passing an array as a query parameter #10

Closed willbrowningme closed 7 years ago

willbrowningme commented 7 years ago

When trying to pass an array of data as a query parameter for example:

?countries[]=germany&countries[]=france&countries[]=ireland

It throws the error:

UnknownColumnException in QueryBuilder.php line 254:
Unknown column 'countries[]'

Is there a way to tell it to ignore the '[]' after countries so that the array can be passed correctly and then used as a custom filter as below:

return $query->whereIn('country', $countries);
selahattinunlu commented 7 years ago

Hi @tttwb, It does not support whereIn for now. But maybe you can try custom filter.

https://github.com/selahattinunlu/laravel-api-query-builder/wiki/Creating-Custom-Filter Let me know please whether 'custom filters' solved your issue.

Also, I will work to add whereIn query support.

selahattinunlu commented 7 years ago

Hi again @tttwb

I added whereIn and whereNotIn support. You can check this out https://github.com/selahattinunlu/laravel-api-query-builder/commit/ea5432334c0a31465777480860e1c6016670d5ec

Please run "composer update" to get changes.

And I added some examples to use it. https://github.com/selahattinunlu/laravel-api-query-builder/wiki/Other-Examples#where-queries You can see it bottom of "Where Queries" section.