https://github.com/lee-to/moonshine-algolia-search
https://github.com/lee-to/moonshine-algolia-search
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/lee-to/moonshine-algolia-search
- Owner: lee-to
- License: mit
- Created: 2023-05-01T14:00:35.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-05-02T15:38:25.000Z (about 2 years ago)
- Last Synced: 2024-12-28T11:30:22.983Z (6 months ago)
- Language: Blade
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
### Algolias search for MoonShine
As a result, all menu items will be indexed, including groups, resources, resource entries and custom pages
### Installation
```shell
composer require lee-to/moonshine-algolia-search
```Publish config
```shell
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`
```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)
```php
// ...
'header' => 'algolia-search::global-search'
// ...
```Create indexes
```shell
php artisan algolia-search:indexes
```If you want to customize fields for models, implement the HasGlobalAlgoliaSearch interface
```php
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
];
}
}
```