Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87b267a

Browse files
committed
Adding array wheres.
1 parent 40e2cf7 commit 87b267a

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/Illuminate/Database/Query/Builder.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,20 @@ public function rightJoinWhere($table, $one, $operator, $two)
383383
*/
384384
public function where($column, $operator = null, $value = null, $boolean = 'and')
385385
{
386+
// If the column is an array, we will assume it is an array of key-value pairs
387+
// and can add them each as a where clause. We will maintain the boolean we
388+
// received when the method was called and pass it onto the other wheres.
389+
if (is_array($column))
390+
{
391+
foreach ($column as $innerKey => $innerValue)
392+
{
393+
$this->where($innerKey, '=', $innerValue, $boolean);
394+
}
395+
}
396+
397+
// Here we will make some assumptions about the operator. If only 2 values are
398+
// passed to the method, we will assume that the operator is an equals sign
399+
// and keep going. Otherwise, we'll require the operator to be passed in.
386400
if (func_num_args() == 2)
387401
{
388402
list($value, $operator) = array($operator, '=');

0 commit comments

Comments
 (0)