Using a single array to pass multiple WHERE conditions (with LIKE) Using a single array to pass multiple WHERE conditions (with LIKE) php php

Using a single array to pass multiple WHERE conditions (with LIKE)


No not really. But internally Laravel just does it with a loop as well.

Illuminate\Database\Query\Builder@where

if (is_array($column)){    return $this->whereNested(function($query) use ($column)    {        foreach ($column as $key => $value)        {            $query->where($key, '=', $value);        }    }, $boolean);}

I suggest you do something like this:

$condition = array(                'field_1' => '%value_1%',                'field_2' => '%value_2%'             );$users = User::where(function($q) use ($condition){    foreach($condition as $key => $value){        $q->where($key, 'LIKE', $value);    }})->get();