I\'m using the Laravel Eloquent query builder and I have a query where I want a WHERE
clause on multiple conditions. It works, but it\'s not elegant.
E
The whereColumn
method can be passed an array of multiple conditions. These conditions will be joined using the and
operator.
Example:
$users = DB::table('users')
->whereColumn([
['first_name', '=', 'last_name'],
['updated_at', '>', 'created_at']
])->get();
$users = User::whereColumn([
['first_name', '=', 'last_name'],
['updated_at', '>', 'created_at']
])->get();
For more information check this section of the documentation https://laravel.com/docs/5.4/queries#where-clauses