Skip to content

Commit

Permalink
[10.x] Optional field definitions on model (#812)
Browse files Browse the repository at this point in the history
* Optional field definitions
Check if field definitions has been added on the model and use if that is the case

* Update TypesenseEngine.php

* Update TypesenseEngine.php

---------

Co-authored-by: Morten D. Hansen <mdh@eltwin.com>
Co-authored-by: Taylor Otwell <taylor@laravel.com>
  • Loading branch information
3 people authored Mar 21, 2024
1 parent 8783042 commit da58ba9
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Engines/TypesenseEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ protected function getOrCreateCollectionFromModel($model): TypesenseCollection
} catch (ObjectNotFound $exception) {
$schema = config('scout.typesense.model-settings.'.get_class($model).'.collection-schema') ?? [];

if (method_exists($model, 'typesenseCollectionSchema')) {
$schema = $model->typesenseCollectionSchema();
}

if (! isset($schema['name'])) {
$schema['name'] = $model->searchableAs();
}
Expand Down

0 comments on commit da58ba9

Please sign in to comment.