Eloquent ORM with parentheses
If you are dealing with multiple AND and OR statements in your queries You will want to use parentheses to logically separate your query.
In Laravel 4 there is a easy way to do so:
$realestates = $realestates
->where( function ( $query )
{
$query->whereBetween('price', array(Input::get('min_price'), Input::get('max_price')))
->orwhereBetween('price_per_day', array(Input::get('min_price'), Input::get('max_price')));
});
Written by Mario Basic
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Laravel
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#