whereBetween方法验证列的值介于两者之间
两个值.
$from = date('2018-01-01');
$to = date('2018-05-02');
Reservation::whereBetween('reservation_from', [$from, $to])->get();
如果您想添加更多条件,则可以使用orWhereBetween.如果要排除日期间隔,则可以使用whereNotBetween.
Reservation::whereBetween('reservation_from', [$from1, $to1])
->orWhereBetween('reservation_to', [$from2, $to2])
->whereNotBetween('reservation_to', [$from3, $to3]);
->get();
其他有用的where子句:whereIn,whereNotIn,whereNull,whereNotNull,whereDate,whereMonth,whereDay,whereYear,whereTime,whereColumn,whereExists,whereRaw.