vyuldashev / nova-column-filter
A Laravel Nova database column filter.
Installs: 86 177
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 1
Forks: 1
Open Issues: 4
Requires
- php: >=7.1.0
This package is auto-updated.
Last update: 2024-12-07 11:07:55 UTC
README
Installation
You can install the package in to a Laravel app that uses Nova via composer:
composer require vyuldashev/nova-column-filter
Usage
Simple filter using equals constraint:
<?php declare(strict_types=1); namespace App\Nova\Filters; use Vyuldashev\NovaColumnFilter\ColumnFilter; class EmailFilter extends ColumnFilter { public $name = 'Email'; public $column = 'email'; }
Advanced filter with custom query:
<?php declare(strict_types=1); namespace App\Nova\Filters; use Illuminate\Http\Request; use Illuminate\Support\Carbon; use Laravel\Nova\Filters\DateFilter; class CreatedAtFromFilter extends DateFilter { public $name = 'Created at from'; public function apply(Request $request, $query, $value): object { $value = Carbon::parse($value); return $query->where('created_at', '>=', $value->startOfDay()); } }