Tucker-Eric / EloquentFilter

An Eloquent Way To Filter Laravel Models And Their Relationships
http://tucker-eric.github.io/EloquentFilter
MIT License
1.72k stars 120 forks source link

filtering by date interval #169

Closed jenya87 closed 2 years ago

jenya87 commented 2 years ago

Hello! I use latest package version on laravel 5.8. I have date field in my db table and two input fields date_start and date_end and need to filter data where date between date_start and date_end

According to a filter logic I need to declare method date in my model filter like this (for more or equal for example)

<?php 
namespace App\ModelFilters;
use EloquentFilter\ModelFilter;
class CardFilter extends ModelFilter
{

    public $relations = [];

    public function date()
    {
    return $this->where('date','>=',Carbon::parse($this->input('date_start'))->format('Y-m-d'));
    }
}

But how to declare method which will filter by date between ``date_startanddate_end``` input values?

Thanks!

jenya87 commented 2 years ago

Sorry, I stumbled