lee-to / moonshine-algolia-search
Algolia global search for MoonShine
Installs: 2 251
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Language:Blade
Requires
- php: ^8.0|^8.1|^8.2
- ext-curl: *
- ext-json: *
- algolia/algoliasearch-client-php: ^3.3
Requires (Dev)
- brianium/paratest: ^6.8
- mockery/mockery: ^1.4.4
- orchestra/testbench: ^4.0|^5.0|^6.0|^7.0|^8.0
- phpstan/phpstan: ^1.4.7
- phpunit/phpunit: ^9.5.8
Conflicts
- moonshine/moonshine: <1.55
This package is auto-updated.
Last update: 2025-03-01 00:32:09 UTC
README
Algolias search for MoonShine
As a result, all menu items will be indexed, including groups, resources, resource entries and custom pages
Installation
composer require lee-to/moonshine-algolia-search
Publish config
php artisan vendor:publish --provider="Leeto\MoonShineAlgoliaSearch\Providers\MoonShineAlgoliaSearchServiceProvider"
Register on the https://www.algolia.com, get the keys and set in config config/algolia.php
return [ 'app_id' => env('ALGOLIA_APP_ID'), 'admin_key' => env('ALGOLIA_ADMIN_KEY'), 'frontend_key' => env('ALGOLIA_FRONTEND_KEY'), ];
MoonShine config (app/moonshine.php)
// ... 'header' => 'algolia-search::global-search' // ...
Create indexes
php artisan algolia-search:indexes
If you want to customize fields for models, implement the HasGlobalAlgoliaSearch interface
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 ]; } }