Laravel 5 WhereIn两列

时间:2016-06-03 21:18:53

标签: laravel laravel-5.2

我有两列:average_minaverage_max

如果average_min=2000average_max=7000,我需要查找interval介于2000-7000之间的记录:

$q->whereAverage_minAndAverage_max($data['average_min'], $data['average_max']);

whereFooAndBar不合适。

1 个答案:

答案 0 :(得分:0)

它可能不是一个完整的代码,但问题已解决:)

if($data['average_min']){
            $q->where('average_min','<=',$data['average_min']);
            $q->where('average_max','>',$data['average_min']);
        }

        if($data['average_max']){
            $q->where('average_min','<=',$data['average_max']);
            $q->where('average_max','>=',$data['average_max']);
        }