Skip to content

Simple Laravel Nova input filter. Works as additional search field out of the box.

License

Notifications You must be signed in to change notification settings

outl1ne/nova-input-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0a5d650 · Jan 17, 2025

History

42 Commits
Jul 8, 2022
Jan 17, 2025
Jan 19, 2021
Jan 17, 2025
Jan 17, 2025
Jan 17, 2025
Jan 19, 2021
Jan 19, 2021
Jan 19, 2021
Jan 19, 2021
Jan 19, 2021
Feb 27, 2024
Jul 8, 2022
Jan 17, 2025
Jan 17, 2025
Jan 17, 2025
Jan 17, 2025
Jan 17, 2025
Jul 8, 2022
Jan 17, 2025
Jan 17, 2025
Jan 17, 2025

Repository files navigation

Nova Input Filter

Latest Version on Packagist Total Downloads

This Laravel Nova package allows you to create simple input filters.

Requirements

  • php: >=8.1
  • laravel/nova: ^5.0

Features

  • Out of the box, works like an additional search field.
  • Inline usage for simple use-cases.

Screenshots

Input filter

Installation

Install the package in to a Laravel app that uses Nova via composer:

composer require outl1ne/nova-input-filter

Usage

Accepts an array of columns as first parameter and filter name as second parameter. Can optionally pass in multiple columns: ['email', 'id'], similarly to nova's search.

use Outl1ne\NovaInputFilter\InputFilter;
use Laravel\Nova\Http\Requests\NovaRequest;

// ..

public function filters(NovaRequest $request): array
{
    return [
        InputFilter::make()->forColumns(['email'])->withName('Email'),

        // Or

        InputFilter::make(['email'], 'email'),
    ];
}

Customizing

Out of the box, InputFilter works exactly like Nova's search field. If you wish to change it, you can extend the InputFilter class and override apply() function.

use Outl1ne\NovaInputFilter\InputFilter;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Laravel\Nova\Http\Requests\NovaRequest;

class ExtendedInputFilter extends InputFilter
{
    public function apply(NovaRequest $request, Builder $query, mixed $value)
    {
        return $query->where('email', 'like', "%$value%");
    }
}

Credits

License

Nova Input Filter is open-sourced software licensed under the MIT license.