Laravel Community Tools by Tighten
Laravel Nova icon Nova Packages
N

Text Auto-Complete Field

Readme

Laravel Nova Text Auto-Complete

This Nova field provides a capability of auto-completed searching for results inside a text input field.

Nova text with autocomplete demo

Installation

You can install the Nova field in to a Laravel app that uses Nova via composer:

composer require gkermer/nova-text-auto-complete

Usage

To add an autocomplete text field, use the Gkermer\TextAutoComplete\TextAutoComplete field in your Nova resource:

use Gkermer\TextAutoComplete\TextAutoComplete;
TextAutoComplete::make('Favourite Fruit')->items([
    'Apple',
    'Apricots',
    'Avocado',
    'Banana',
    'Blueberries',
]),

Assuming you have an Eloquent model Fruit with attribute name, you could get the items by:

TextAutoComplete::make('Favourite Fruit')->items(
    Fruit::pluck('name')
),

However, imagine the Fruit has hundreds or thousands records and the drop-down selection menu is populated with so many items. Then you could find the items like so:

TextAutoComplete::make('Favourite Fruit')->items(function($search) {
    return Fruit::where('name', 'like', '%' . $search . '%')
        ->get()
        ->pluck('name');
}),

License

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

Reviews

By Flame on February 16, 2022

easy to use!

Back to Top
Added 7 years ago
Last updated 5 Years Ago
Version 0.0.5
Composer
gkermer/nova-text-auto-complete
GitHub stars 22
Packagist downloads 114,926

Favorites

17 users favorited

Rating

5.00
(out of 5)
★★★★★
★★★★
★★★
★★
2 ratings

Author

Brought to you by Tighten

Issues/Feature Requests Stats Package Ideas