mirror of
https://gh.wpcy.net/https://github.com/aspirepress/AspireCloud.git
synced 2026-06-01 00:19:09 +08:00
31 lines
755 B
PHP
31 lines
755 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Providers;
|
|
|
|
use Elastic\Elasticsearch\Client;
|
|
use Elastic\Elasticsearch\ClientBuilder;
|
|
use Illuminate\Contracts\Support\DeferrableProvider;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class ElasticsearchServiceProvider extends ServiceProvider implements DeferrableProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
$this
|
|
->app
|
|
->singleton(
|
|
Client::class,
|
|
fn () => ClientBuilder::create()
|
|
->setHosts([config('elasticsearch.host')])
|
|
->build()
|
|
);
|
|
}
|
|
/**
|
|
* @return array<class-string>
|
|
*/
|
|
public function provides(): array
|
|
{
|
|
return [Client::class];
|
|
}
|
|
}
|