Laravel Eloquent query with optional parameters -


I am trying to figure out whether to pass a variable number of parameters in a query in the echo The easiest way is, hopefully using a array .

There is no way to do this without looping through the input of what I can get, see what was set in the request.

Here the example:

This will work, but in its complexity / interest, I experience non-larval.

Here's where I am, and this is not possible, just someone else has solved the same problem:

  $ where = array ("user_id" "=> 123," status "=> 0," some more "=) & gt; "Some values"); $ Order = order :: where ($ where) - & gt; Find () - & gt; ToArray (); Return Feedback: JSON (array ('order' =>> $ order), 200);  

This returns an error on the course strtolower () is expected to be a string of parameter 1, given array .

Is this possible?

Order :: Where actually provides an example of a query builder, it is probably easier than you think. If you just want to get that example of the query builder and want to "build" your query, at a time (where) you can get it like this:

  $ Qb = (new order) -> New Question (); Foreign currency ($ Search = $ purse => $ v) {$ qb-> Where ($ k, $ v); } $ Qb- & gt; Retrieve (); / />  

If you ever want to see what the query builder is doing then you can get it () and shortly:

  dd ( \ DB :: getQueryLog ());  

This will show you what the result looks like; It can be very useful while playing with lucrative.


Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -