PHP code example of malzariey / filament-daterangepicker-filter

1. Go to this page and download the library: Download malzariey/filament-daterangepicker-filter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

malzariey / filament-daterangepicker-filter example snippets


use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangePicker::make('created_at'),

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;

DateRangeFilter::make('created_at'),

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->timezone('UTC')
DateRangePicker::make('created_at')->timezone('UTC')

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;


DateRangeFilter::make('created_at')->startDate(Carbon::now())->endDate(Carbon::now())
DateRangePicker::make('created_at')->startDate(Carbon::now())->endDate(Carbon::now())

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->defaultToday()
DateRangePicker::make('created_at')->defaultToday()

DateRangeFilter::make('created_at')->defaultYesterday()
DateRangePicker::make('created_at')->defaultYesterday()

DateRangeFilter::make('created_at')->defaultLast7Days()
DateRangePicker::make('created_at')->defaultLast7Days()

DateRangeFilter::make('created_at')->defaultLast30Days()
DateRangePicker::make('created_at')->defaultLast30Days()

DateRangeFilter::make('created_at')->defaultThisMonth()
DateRangePicker::make('created_at')->defaultThisMonth()

DateRangeFilter::make('created_at')->defaultLastMonth()
DateRangePicker::make('created_at')->defaultLastMonth()

DateRangeFilter::make('created_at')->defaultThisYear()
DateRangePicker::make('created_at')->defaultThisYear()

DateRangeFilter::make('created_at')->defaultLastYear()
DateRangePicker::make('created_at')->defaultLastYear()

use Carbon\Carbon;
DateRangeFilter::make('created_at')->defaultCustom(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth())
DateRangePicker::make('created_at')->defaultCustom(Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth())

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->minDate(Carbon::now()->subMonth())->maxDate(Carbon::now()->addMonth())
DateRangePicker::make('created_at')->minDate(Carbon::now()->subMonth())->maxDate(Carbon::now()->addMonth())

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->firstDayOfWeek(1)
DateRangePicker::make('created_at')->firstDayOfWeek(1)

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->alwaysShowCalendar()
DateRangePicker::make('created_at')->alwaysShowCalendar()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->timePicker()
DateRangePicker::make('created_at')->timePicker()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->timePickerSecond()
DateRangePicker::make('created_at')->timePickerSecond()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->timePicker24()
DateRangePicker::make('created_at')->timePicker24()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->timePickerIncrement(30)
DateRangePicker::make('created_at')->timePickerIncrement(30)

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->autoApply()
DateRangePicker::make('created_at')->autoApply()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->linkedCalendars()
DateRangePicker::make('created_at')->linkedCalendars()

use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangePicker::make('created_at')->singleCalendar()



use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->disabledDates(['array of Dates'])
DateRangePicker::make('created_at')->disabledDates(['array of Dates'])

DateRangeFilter::make('created_at')
//Picker Date Display Format in (Javascript Date Format)
->displayFormat('date format')
//Carbon Format reading from the Javascript displayFormat in (PHP Date Format)
->format('date format')

DateRangePicker::make('created_at')
->displayFormat('date format')
->format('date format')

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Illuminate\Database\Eloquent\Builder;
use Carbon\Carbon;

DateRangeFilter::make('created_at')
    ->modifyQueryUsing(fn(Builder $query, ?Carbon $startDate , ?Carbon $endDate , $dateString) =>
        $query->when(!empty($dateString),
            fn (Builder $query, $date) : Builder =>
                $query->whereBetween('created_at', [$startDate->subDays(3),$endDate]))
    )

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;


DateRangePicker::make('created_at')->withIndicator()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;


DateRangeFilter::make('created_at')
->ranges(['Last 3 days' => [now()->subDays(3), now()]])

DateRangePicker::make('created_at')
->ranges(['Last 3 days' => [now()->subDays(3), now()]])

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;


DateRangeFilter::make('created_at')->useRangeLabels()
DateRangePicker::make('created_at')->useRangeLabels()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;


DateRangeFilter::make('created_at')->disableCustomRange()
DateRangePicker::make('created_at')->disableCustomRange()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;


DateRangeFilter::make('created_at')->separator(' - ')
DateRangePicker::make('created_at')->separator(' - ')

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

use Malzariey\FilamentDaterangepickerFilter\Enums\DropDirection;

DateRangeFilter::make('created_at')->drops(DropDirection::AUTO)
DateRangePicker::make('created_at')->drops(DropDirection::AUTO)

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

use Malzariey\FilamentDaterangepickerFilter\Enums\OpenDirection;


DateRangeFilter::make('created_at')->opens(OpenDirection::LEFT)
DateRangePicker::make('created_at')->opens(OpenDirection::LEFT)

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->disableClear()
DateRangePicker::make('created_at')->disableClear()

DateRangeFilter::make('created_at')->icon('heroicons-backspace')
DateRangePicker::make('created_at')->icon('heroicons-backspace')

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;



DateRangeFilter::make('created_at')->disableRanges()
DateRangePicker::make('created_at')->disableRanges()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;


DateRangeFilter::make('created_at')->maxSpan(['months' => 1]), // days, months or years
DateRangePicker::make('created_at')->maxSpan(['months' => 1]), // days, months or years

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->showWeekNumbers() // Localized
DateRangePicker::make('created_at')->showISOWeekNumbers()

use Malzariey\FilamentDaterangepickerFilter\Filters\DateRangeFilter;
use Malzariey\FilamentDaterangepickerFilter\Fields\DateRangePicker;

DateRangeFilter::make('created_at')->showDropdowns()->minYear(2000)->maxYear(2030)
DateRangePicker::make('created_at')->showDropdowns()->minYear(2000)->maxYear(2030)