PHP code example of lee-to / moonshine-algolia-search

1. Go to this page and download the library: Download lee-to/moonshine-algolia-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/ */

    

lee-to / moonshine-algolia-search example snippets


return [
    'app_id' => env('ALGOLIA_APP_ID'),
    'admin_key' => env('ALGOLIA_ADMIN_KEY'),
    'frontend_key' => env('ALGOLIA_FRONTEND_KEY'),
];

// ...
'header' => 'algolia-search::global-search'
// ...

use Illuminate\Database\Eloquent\Model;
use Leeto\MoonShineAlgoliaSearch\Contracts\HasGlobalAlgoliaSearch;

class Post extends Model implements HasGlobalAlgoliaSearch
{
    public function globalSearch(): array
    {
        return [
            'description' => $this->text,
            'image' => $this->thumbnail
        ];
    }
}
shell
php artisan vendor:publish --provider="Leeto\MoonShineAlgoliaSearch\Providers\MoonShineAlgoliaSearchServiceProvider"
shell
php artisan algolia-search:indexes