diff --git a/src/Attributes/SearchUsingFullText.php b/src/Attributes/SearchUsingFullText.php index df9f6928..a40144e6 100644 --- a/src/Attributes/SearchUsingFullText.php +++ b/src/Attributes/SearchUsingFullText.php @@ -15,14 +15,20 @@ class SearchUsingFullText */ public $columns = []; + /** + * The full-text options. + */ + public $options = []; + /** * Create a new attribute instance. * * @param array|string $columns * @return void */ - public function __construct($columns) + public function __construct($columns, $options = []) { $this->columns = Arr::wrap($columns); + $this->options = Arr::wrap($options); } } diff --git a/src/Attributes/SearchUsingOptions.php b/src/Attributes/SearchUsingOptions.php deleted file mode 100644 index dca16361..00000000 --- a/src/Attributes/SearchUsingOptions.php +++ /dev/null @@ -1,23 +0,0 @@ -options = Arr::wrap($options); - } -} diff --git a/src/Engines/DatabaseEngine.php b/src/Engines/DatabaseEngine.php index b3246b9a..6d8a830e 100644 --- a/src/Engines/DatabaseEngine.php +++ b/src/Engines/DatabaseEngine.php @@ -283,14 +283,23 @@ protected function getAttributeColumns(Builder $builder, $attributeClass) /** * Get the full-text search options for the query. + * + * @param \Laravel\Scout\Builder $builder + * @return array */ protected function getFullTextOptions(Builder $builder) { - $reflection = new ReflectionMethod($builder->model, 'toSearchableArray'); + $options = []; - if ($attribute = collect($reflection->getAttributes(SearchUsingOptions::class))->first()) { - return collect($attribute->getArguments())->first(); + if (PHP_MAJOR_VERSION < 8) { + return []; } + + foreach ((new ReflectionMethod($builder->model, 'toSearchableArray'))->getAttributes(SearchUsingFullText::class) as $attribute) { + $columns = array_merge($options, Arr::wrap($attribute->getArguments()[1])); + } + + return $columns; } /**