php - Laravel REST API: Translating query string parameters into database search queries -


I used Laravel 4 & amp; Eloquent I have read some details about writing a good API, in which Phil & amp; Apigee's

About complex complexity, it may be cumbersome to obtain parameters from the API negotiation query string, because the query number can vary in number & amp; types of. For example, to get a dog with a black color, request

  http://url.com/api/dogs?color=black   

And Dogs With Black & amp; Age will

  http://url.com/api/dogs?color=black&age=16 $ dogs = new dog; If (Input :: find ('color')) $ houses- & gt; Where ('color', '=', input :: find ('color')); If (Input :: find ('age')) $ houses- & gt; Where ('age', '=', input :: mill ('age')); // Keep adding more for each filter: - | $ Dogs = $ dogs- & gt; Go ();   

An alternate & amp; Even then, a better method was to use the DB column names as the ultimate names and an advance option was used to generate a query.

However, I was wondering if there was a standard way to handle Optional for this approach or if it is to handle the query string.

I think if you have 3-4 criteria then you can check them indefinitely as You have done above.

But if you have many parameters, then you can use the foreclosure loop, be careful to avoid searches from hidden areas (like ID) .. Example below. < Pre> $ inputs = input :: except ('id', 'some_cannot_be_used_for_searching'); Foreign currency ($ input => $ input as the $ key) {// STAME}

Tell me if there is any other problem thanks :)

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -