PHP code example of jonassiewertsen / statamic-live-search

1. Go to this page and download the library: Download jonassiewertsen/statamic-live-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/ */

    

jonassiewertsen / statamic-live-search example snippets


'blog' => [
     'driver' => 'local',
     'searchables' => 'collection:blog',
     'fields' => ['title'],
 ],

namespace App\Your\Namespace;

use Jonassiewertsen\LiveSearch\Http\Livewire\Search;

class YourCustomLivewireController extends Search
{
    public $template;
    public $index;

    public function mount(string $template, string $index = null)
    {
        // You can pass these as parameters or they can be hardcoded. 
        $this->template = $template;
        $this->index = $index;
    }

    public function render()
    {
        // Do your stuff here. 
    
        return view($this->template, [
            'results' => $this->search($this->q, $this->index),
        ]);
    }
}
bash
php artisan vendor:publish --tag=live-search:views