lowerrocklabs/laravel-livewire-tables-daterangefilter

This package is abandoned and no longer maintained. The author suggests using the lowerrocklabs/laravel-livewire-tables-advanced-filters package instead.

A DateRange filter for Rappasoft Laravel Livewire Tables using FlatPickr

v0.2-alpha 2023-01-31 23:30 UTC

This package is auto-updated.

Last update: 2023-02-27 01:40:23 UTC


README

68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6f776572726f636b6c6162732f6c61726176656c2d6c697665776972652d7461626c65732d6461746572616e676566696c7465722e7376673f7374796c653d666c61742d737175617265 GitHub Tests Action Status GitHub Code Style Action Status 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f64653432653366303564306362313632396338642f6d61696e7461696e6162696c697479 68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6c6f776572726f636b6c6162732f6c61726176656c2d6c697665776972652d7461626c65732d6461746572616e676566696c746572

This model allows for a DateRange filter within Rappasoft's Livewire Tables package which is required.

Installation

Requires [PHP 7.3+ or 8.0+] and [Laravel 8.x or 9.x] (https://laravel.com/docs/8.x/releases or https://laravel.com/docs/9.x/releases)

Requires RappaSoft Livewire Tables

You will need to install FlatPickr, see here for instructions: https://flatpickr.js.org/getting-started/#installation

You can then install this package via composer:

composer require lowerrocklabs/laravel-livewire-tables-daterangefilter

You can publish the config file with:

php artisan vendor:publish --tag="laravel-livewire-tables-daterangefilter-config"

Including the DateRangeFilter in your table:

use LowerRockLabs\LaravelLivewireTablesDateRangeFilter\DateRangeFilter;

Creating a filter:

DateRangeFilter::make('Upload Date')
->config([
    'minDate' => '2020-01-01',
    'maxDate' => date('Y-m-d'),
    'defaultStartDate' => date('Y-m-d'),
    'defaultEndDate' => date('Y-m-d'),
    'altFormat' => 'F j, Y',
    'allowInput' => true
    ])
    ->filter(function (Builder $builder, string $dates) {
    $dateRange = explode(' ', $dates);
    $builder->where('**FIELDNAME**', '>=', $dateRange[0])
        ->where('**FIELDNAME**', '<=', (isset($dateRange[2])) ? $dateRange[2] : date('Y-m-d'));
});

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.