PHP code example of lhilton / text-auto-complete

1. Go to this page and download the library: Download lhilton/text-auto-complete library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lhilton / text-auto-complete example snippets


use Lhilton\TextAutoComplete\TextAutoComplete;

public function fields(Request $request)
{
    return [
        TextAutoComplete::make('Regions')->items([
            'Alabama',
            'Alaska',
            'Arizona',
            'Arkansas',
            // ...
            'West Virginia',
            'Wisconsin',
            'Wyoming'
        ]),
    ];
}

use App\Models\User;
use Lhilton\TextAutoComplete\TextAutoComplete;

public function fields(Request $request)
{
    return [
        TextAutoComplete::make('Regions')->items(
            User::select('title')
                ->distinct()
                ->get()
                ->pluck('title')
                ->filter()
                ->values()
                ->toArray();
        ),
    ];
}