How to Create Multiple Where Clause Query Using Laravel Eloquent?

前端 未结 24 1419
一整个雨季
一整个雨季 2020-11-22 14:30

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

24条回答
  •  借酒劲吻你
    2020-11-22 15:26

    $variable = array('this' => 1,
                        'that' => 1
                        'that' => 1,
                        'this_too' => 1,
                        'that_too' => 1,
                        'this_as_well' => 1,
                        'that_as_well' => 1,
                        'this_one_too' => 1,
                        'that_one_too' => 1,
                        'this_one_as_well' => 1,
                        'that_one_as_well' => 1);
    
    foreach ($variable as $key => $value) {
        User::where($key, '=', $value);
    }
    

提交回复
热议问题