Loading src/Filter/Date.php +6 −2 Original line number Diff line number Diff line Loading @@ -14,10 +14,14 @@ final class Date extends HttpFilter public function addToQuery(QueryBuilder $queryBuilder): QueryBuilder { $queryBuilder->where( 'strftime(\'%Y-%m-%d\', ' . $this->getColumn() . ') = :' . $this->getParameterKey(), 'SUBSTRING(' . $this->getColumn() . ', 0, 11) = :' . $this->getParameterKey(), ); if ($this->getHttpValue() === null) { if (is_null($this->getHttpValue())) { throw new FilterParameterValueIsNullException($this->field); } if (! \DateTimeImmutable::createFromFormat('Y-m-d', $this->getHttpValue())) { throw new FilterParameterValueIsNullException($this->field); } Loading src/Filter/DateRange.php +18 −9 Original line number Diff line number Diff line Loading @@ -13,20 +13,29 @@ final class DateRange extends HttpFilter /** @throws FilterParameterValueIsNullException */ public function addToQuery(QueryBuilder $queryBuilder): QueryBuilder { if (! isset($this->getHttpValue()['from']) && ! isset($this->getHttpValue()['to'])) { $httpValues = $this->getHttpValue(); $fromDate = $httpValues['from'] ?? null; $toDate = $httpValues['to'] ?? null; if (is_null($fromDate) && is_null($toDate)) { throw new FilterParameterValueIsNullException($this->field); } $fromDate = \DateTimeImmutable::createFromFormat('Y-m-d', $fromDate ?? ''); $toDate = \DateTimeImmutable::createFromFormat('Y-m-d', $toDate ?? ''); if (! $fromDate && ! $toDate){ throw new FilterParameterValueIsNullException($this->field); } if (isset($this->getHttpValue()['from'])) { $queryBuilder->where( 'strftime(\'%Y-%m-%d\', ' . $this->getColumn() . ') >= \'' . $this->getHttpValue()['from'] . '\'', ); if ($fromDate) { $queryBuilder->where($this->getColumn() . ' >= :fromDate') ->setParameter('fromDate', $fromDate->setTime(0, 0, 0)); } if (isset($this->getHttpValue()['to'])) { $queryBuilder->andWhere( 'strftime(\'%Y-%m-%d\', ' . $this->getColumn() . ') <= \'' . $this->getHttpValue()['to'] . '\'', ); if ($toDate) { $queryBuilder->andWhere($this->getColumn() . ' <= :toDate') ->setParameter('toDate', $toDate->setTime(23, 59, 59)); } return $queryBuilder; Loading Loading
src/Filter/Date.php +6 −2 Original line number Diff line number Diff line Loading @@ -14,10 +14,14 @@ final class Date extends HttpFilter public function addToQuery(QueryBuilder $queryBuilder): QueryBuilder { $queryBuilder->where( 'strftime(\'%Y-%m-%d\', ' . $this->getColumn() . ') = :' . $this->getParameterKey(), 'SUBSTRING(' . $this->getColumn() . ', 0, 11) = :' . $this->getParameterKey(), ); if ($this->getHttpValue() === null) { if (is_null($this->getHttpValue())) { throw new FilterParameterValueIsNullException($this->field); } if (! \DateTimeImmutable::createFromFormat('Y-m-d', $this->getHttpValue())) { throw new FilterParameterValueIsNullException($this->field); } Loading
src/Filter/DateRange.php +18 −9 Original line number Diff line number Diff line Loading @@ -13,20 +13,29 @@ final class DateRange extends HttpFilter /** @throws FilterParameterValueIsNullException */ public function addToQuery(QueryBuilder $queryBuilder): QueryBuilder { if (! isset($this->getHttpValue()['from']) && ! isset($this->getHttpValue()['to'])) { $httpValues = $this->getHttpValue(); $fromDate = $httpValues['from'] ?? null; $toDate = $httpValues['to'] ?? null; if (is_null($fromDate) && is_null($toDate)) { throw new FilterParameterValueIsNullException($this->field); } $fromDate = \DateTimeImmutable::createFromFormat('Y-m-d', $fromDate ?? ''); $toDate = \DateTimeImmutable::createFromFormat('Y-m-d', $toDate ?? ''); if (! $fromDate && ! $toDate){ throw new FilterParameterValueIsNullException($this->field); } if (isset($this->getHttpValue()['from'])) { $queryBuilder->where( 'strftime(\'%Y-%m-%d\', ' . $this->getColumn() . ') >= \'' . $this->getHttpValue()['from'] . '\'', ); if ($fromDate) { $queryBuilder->where($this->getColumn() . ' >= :fromDate') ->setParameter('fromDate', $fromDate->setTime(0, 0, 0)); } if (isset($this->getHttpValue()['to'])) { $queryBuilder->andWhere( 'strftime(\'%Y-%m-%d\', ' . $this->getColumn() . ') <= \'' . $this->getHttpValue()['to'] . '\'', ); if ($toDate) { $queryBuilder->andWhere($this->getColumn() . ' <= :toDate') ->setParameter('toDate', $toDate->setTime(23, 59, 59)); } return $queryBuilder; Loading