Skip to content

Commit

Permalink
add dateFrom and dateTo methods for filtering by date range
Browse files Browse the repository at this point in the history
  • Loading branch information
imahmood committed May 10, 2024
1 parent 19281f9 commit 5492aba
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/BaseFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,24 @@ protected function compare(string $field, string $operator, string $value): self

return $this;
}

protected function dateFrom(string $field, string $date): static
{
if ($date) {
$this->getQuery()->where($field, '>=', $date.' 00:00:00');
}

return $this;
}

protected function dateTo(string $field, string $date): static
{
if ($date) {
$this->getQuery()->where($field, '<=', $date.' 23:59:59');
}

return $this;
}

public function setQuery(QueryBuilder $builder): void
{
Expand Down

0 comments on commit 5492aba

Please sign in to comment.