|
@@ -10,6 +10,11 @@ class Between extends Filter
|
|
{
|
|
{
|
|
protected $dateFormat = null;
|
|
protected $dateFormat = null;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @var bool
|
|
|
|
+ */
|
|
|
|
+ protected $timestamp = false;
|
|
|
|
+
|
|
public function __construct()
|
|
public function __construct()
|
|
{
|
|
{
|
|
$this->class = [
|
|
$this->class = [
|
|
@@ -18,6 +23,18 @@ class Between extends Filter
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Convert the datetime into unix timestamp.
|
|
|
|
+ *
|
|
|
|
+ * @return $this
|
|
|
|
+ */
|
|
|
|
+ public function toTimestamp()
|
|
|
|
+ {
|
|
|
|
+ $this->timestamp = true;
|
|
|
|
+
|
|
|
|
+ return $this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Date filter.
|
|
* Date filter.
|
|
*
|
|
*
|
|
@@ -75,6 +92,14 @@ class Between extends Filter
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ($this->timestamp) {
|
|
|
|
+ $value = array_map(function ($v) {
|
|
|
|
+ if ($v) {
|
|
|
|
+ return strtotime($v);
|
|
|
|
+ }
|
|
|
|
+ }, $value);
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!isset($value['start'])) {
|
|
if (!isset($value['start'])) {
|
|
return $model->where($this->getColumnName(), '<=', $value['end']);
|
|
return $model->where($this->getColumnName(), '<=', $value['end']);
|
|
}
|
|
}
|