laravel/framework — pull request #4819 by JosephSilber (2014-06-24 21:06:04+00:00)
Title: Use nested where for where arrays

I think the way it is currently set up is counter intuitive. Take the following piece of code as an example:

$attributes1 = ['fname' => 'Taylor', 'lname' => 'Otwell'];
$attributes2 = ['fname' => 'Joseph', 'lname' => 'Silber'];

$users = User::where($attributes1)->orWhere($attributes2)->get();

With the way it is currently set up, this'll run the following query:

select *
from `users`
where `fname` = 'Taylor' and `lname` = 'Otwell'
or `fname` = 'Joseph' or `lname` = 'Silber'

I think this is obviously wrong.

After the PR, the code above will run this query:

select *
from `users`
where (`fname` = 'Taylor' and `lname` = 'Otwell')
or (`fname` = 'Joseph' and `lname` = 'Silber')