sunchain-fr / nova-dates-pill-filter
A Laravel Nova filter.
Installs: 356
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:Vue
Requires
- php: >=7.4.0
This package is auto-updated.
Last update: 2024-11-29 06:16:22 UTC
README
A date filter to use with Nova Dashboard.
Installation
You can install the package via composer:
composer require sunchain-fr/nova-dates-pill-filter
Usage
Register the DatesPillFilter
filter within your view`
use Sunchain\NovaDatesPillFilter\DatesPillFilter; class MainView extends View { public function filters(): array { return [ new DatesPillFilter() ]; } }
The filter will give you 2 fields, $from
and $to
<?php namespace App\Nova\Dashboards\Widgets; use Carbon\Carbon; use DigitalCreative\NovaDashboard\Filters; use DigitalCreative\ValueWidget\Widgets\ValueResult; use DigitalCreative\ValueWidget\Widgets\ValueWidget; use Illuminate\Support\Collection; use Sunchain\NovaDatesPillFilter\DatesPillFilter; class MyValueWidget extends ValueWidget { public function resolveValue(Collection $options, Filters $filters): ValueResult { $dates = $filters->getFilterValue(DatesPillFilter::class); $from = Carbon::now()->subWeek(); $to = Carbon::now(); if (isset($dates['from']) && $dates['from'] != "") { $from = $dates['from']; } if (isset($dates['to']) && $dates['to'] != "") { $to = $dates['to']; } // build your query with $from and $to filters // ... } }
⭐️ Show Your Support
Please give a ⭐️ if this project helped you!
License
The MIT License (MIT). Please see License File for more information.