Below is an excerpt from the Laravel documentation:
The whereBetween method verifies that a column\'s value is between two values:
$users = DB::
There is no alternative to the whereBetween
method that applies to two columns. You can however do this in one of two ways:
1. Use whereRaw
with bindings, where you use the raw condition and a binding for the variable:
whereRaw('? between saturday_ot and saturday_ct', [$t])
2. Use a where
with two conditions that use the two column values as boundaries for the $t
variable value:
where(function ($query) use ($t) {
$query->where('saturday_ot', '<=', $t);
$query->where('saturday_ct', '>=', $t);
})