diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index d60d52c..9d082ad 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ubuntu-latest] php: [8.3, 8.4] - laravel: [11.*, 12.*] + laravel: [12.*] stability: [prefer-lowest, prefer-stable] name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index c9b97e8..8315ec2 100644 --- a/composer.json +++ b/composer.json @@ -27,12 +27,13 @@ "meilisearch/meilisearch-php": "^1.0", "guzzlehttp/guzzle": "^7.3", "http-interop/http-factory-guzzle": "^1.0", - "illuminate/support": "^10.0 || ^11.0 || ^12.0", - "statamic/cms": "^6.0" + "illuminate/support": "^12.0", + "statamic/cms": "^6.0.0-beta.4", + "spatie/laravel-ray": "^1.0@dev" }, "require-dev": { "laravel/pint": "^1.21", - "orchestra/testbench": "^9.0 || ^10.0", + "orchestra/testbench": "^10.0", "phpunit/phpunit": "^11.5.10" }, "autoload": { @@ -68,5 +69,6 @@ "developer": "Statamic Rad Pack" } }, - "minimum-stability": "dev" + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/config/statamic-meilisearch.php b/config/statamic-meilisearch.php deleted file mode 100644 index b8d3706..0000000 --- a/config/statamic-meilisearch.php +++ /dev/null @@ -1,9 +0,0 @@ - 100, - -]; diff --git a/src/Meilisearch/Index.php b/src/Meilisearch/Index.php index 5b0fa55..d15dbb5 100644 --- a/src/Meilisearch/Index.php +++ b/src/Meilisearch/Index.php @@ -31,23 +31,12 @@ public function insert($document) return $this->insertMultiple(collect([$document])); } - public function insertMultiple($documents) - { - $documents - ->chunk(config('statamic-meilisearch.insert_chunk_size', 100)) - ->each(function ($documents, $index) { - $documents = $documents - ->map(fn ($document) => array_merge( - $this->searchables()->fields($document), - $this->getDefaultFields($document), - )) - ->values() - ->toArray(); - - $this->insertDocuments(new Documents($documents)); - }); - - return $this; + public function fields(Searchable $searchable) + { + return array_merge( + $this->searchables()->fields($searchable), + $this->getDefaultFields($searchable) + ); } public function delete($document) @@ -66,9 +55,9 @@ public function exists() } } - protected function insertDocuments(Documents $documents) + public function insertDocuments(Documents $documents) { - $this->getIndex()->updateDocuments($documents->all()); + $this->getIndex()->updateDocuments($documents->values()->all()); } protected function deleteIndex() diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 3d4a767..761dd06 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -11,16 +11,6 @@ class ServiceProvider extends AddonServiceProvider { public function bootAddon() { - $this->mergeConfigFrom(__DIR__.'/../config/statamic-meilisearch.php', 'statamic-meilisearch'); - - if ($this->app->runningInConsole()) { - - $this->publishes([ - __DIR__.'/../config/statamic-meilisearch.php' => config_path('statamic-meilisearch.php'), - ], 'statamic-meilisearch-config'); - - } - Search::extend('meilisearch', function (Application $app, array $config, $name, $locale = null) { $client = $app->makeWith(Client::class, [ 'url' => $config['credentials']['url'], diff --git a/tests/TestCase.php b/tests/TestCase.php index 1d1ede1..9c05325 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,7 +15,6 @@ protected function resolveApplicationConfiguration($app) { parent::resolveApplicationConfiguration($app); - // add driver $app['config']->set('statamic.search.drivers.meilisearch', [ 'credentials' => [ 'url' => 'http://localhost:7700', @@ -23,7 +22,10 @@ protected function resolveApplicationConfiguration($app) ], ]); - // add index + $app['config']->set('statamic.search.indexes.cp', [ + 'driver' => 'null', + ]); + $app['config']->set('statamic.search.indexes.meilisearch_index', [ 'driver' => 'meilisearch', 'searchables' => ['collection:pages'],