whereBetween($column, [strtotime($timeRange[0]), strtotime($timeRange[1])]); } public function scopeOfMonth($query, $column, $month, $withTime = true) { if (!$month) { return $query; } $firstDate = $month . '-01'; $lastDate = Time::getMonthLastDate($month); $timeRange = Time::dateTimeRange([$firstDate, $lastDate], $withTime); return $query->whereBetween($column, [strtotime($timeRange[0]), strtotime($timeRange[1])]); } public function scopeTimeOverlay($query, $rangeColumns, $timeRange) { return $query->whereNot(function ($q) use ($rangeColumns, $timeRange) { $q->where($rangeColumns[1], '<', $timeRange[0])->orWhere($rangeColumns[0], '<', $timeRange[1]); }); } }