lowerrocklabs / laravel-livewire-tables-daterangefilter
A DateRange filter for Rappasoft Laravel Livewire Tables using FlatPickr
Requires
- php: ^7.4|^8.0
- illuminate/contracts: ^8.0|^9.0
- livewire/livewire: ^2.6
- rappasoft/laravel-livewire-tables: dev-master
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- ext-sqlite3: *
- friendsofphp/php-cs-fixer: ^3.13
- laravel/pint: ^1.2
- nunomaduro/larastan: ^2.2
- orchestra/testbench: ^6.13|^7.0
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.9
This package is auto-updated.
Last update: 2023-02-27 01:40:23 UTC
README
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.