You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In certain situations you may only want certain statements to apply to a query when something else is true. For instance you may only want to apply an `orderBy` statement if the url specified a column to sort on. To do that you would use the `when` method on your query:
386
+
Sometimes you may want statements to apply to a query only when something else is true. For instance you may only want to apply a `where` statement if a given input value is present on the incoming request. You may accomplish this using the `when` method:
The `when` method only applies the changes in the closure when the first parameter evaluates to true. If it evaluates to false, the query continues on without those changes like they don't exist.
396
+
397
+
The `when` method only executes the given Closure when the first parameter is `true`. If the first parameter is `false`, the Closure will not be executed.
0 commit comments