polarcubs's avatar

Is there a orWhereIn in Query Builder

Is there a orWhereIn in Query Builder?

Well I just did a whereIn but I want to to another whereIn. I didn't see the documentation mention it, so I thought I ask here.

0 likes
4 replies
bestmomo's avatar

Yes it is :

/**
 * Add an "or where in" clause to the query.
 *
 * @param  string  $column
 * @param  mixed   $values
 * @return \Illuminate\Database\Query\Builder|static
 */
public function orWhereIn($column, $values)
{
    return $this->whereIn($column, $values, 'or');
}
12 likes
kapitan's avatar

Here's what would it look like:

Model::where('column', $value)->orWhere(function($query) use($my_array){ $query->whereIn('id', $my_array); })->get();

KISS version:

Model::where('column', $value)->orWhereIn('id', $my_array)->get();

martinbean's avatar

@kapitan Was it really necessary to reply to a thread that’s over half a decade old…?

Please or to participate in this conversation.