PHP code example of tnt-freskim-veliu / livewire-spotlight-search

1. Go to this page and download the library: Download tnt-freskim-veliu/livewire-spotlight-search 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/ */

    

tnt-freskim-veliu / livewire-spotlight-search example snippets

 php
return [
    'searchable' => 'App\SpotlightSearch\UserSearch'
];
 php
class UserSearch implements Searchable
{
    public function search(string $query): array
    {
        return User::query()
               ->where('name', 'LIKE', "%$query%")
               ->take(25)
               ->get()
               ->toArray();
    }
    
    public function group()
    {
        return "Users";
    }
    
    public function onSelect($id, Component $component)
    {
        //handle logic when the item is clicked
    }
}