|
5 | 5 | namespace MongoDB\Laravel\Eloquent;
|
6 | 6 |
|
7 | 7 | use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
|
| 8 | +use Illuminate\Database\Eloquent\Collection; |
| 9 | +use Illuminate\Database\Eloquent\Model; |
8 | 10 | use MongoDB\BSON\Document;
|
| 11 | +use MongoDB\Builder\Type\SearchOperatorInterface; |
9 | 12 | use MongoDB\Driver\CursorInterface;
|
10 | 13 | use MongoDB\Driver\Exception\WriteException;
|
11 | 14 | use MongoDB\Laravel\Connection;
|
|
21 | 24 | use function iterator_to_array;
|
22 | 25 | use function property_exists;
|
23 | 26 |
|
24 |
| -/** @method \MongoDB\Laravel\Query\Builder toBase() */ |
| 27 | +/** |
| 28 | + * @method \MongoDB\Laravel\Query\Builder toBase() |
| 29 | + * @template TModel of Model |
| 30 | + */ |
25 | 31 | class Builder extends EloquentBuilder
|
26 | 32 | {
|
27 | 33 | private const DUPLICATE_KEY_ERROR = 11000;
|
@@ -70,9 +76,27 @@ public function aggregate($function = null, $columns = ['*'])
|
70 | 76 | return $result ?: $this;
|
71 | 77 | }
|
72 | 78 |
|
73 |
| - public function search(...$args) |
74 |
| - { |
75 |
| - $results = $this->toBase()->search(...$args); |
| 79 | + /** |
| 80 | + * Performs a full-text search of the field or fields in an Atlas collection. |
| 81 | + * |
| 82 | + * @see https://www.mongodb.com/docs/atlas/atlas-search/aggregation-stages/search/ |
| 83 | + * |
| 84 | + * @return Collection<int, TModel> |
| 85 | + */ |
| 86 | + public function search( |
| 87 | + SearchOperatorInterface|array $operator, |
| 88 | + ?string $index = null, |
| 89 | + ?array $highlight = null, |
| 90 | + ?bool $concurrent = null, |
| 91 | + ?string $count = null, |
| 92 | + ?string $searchAfter = null, |
| 93 | + ?string $searchBefore = null, |
| 94 | + ?bool $scoreDetails = null, |
| 95 | + ?array $sort = null, |
| 96 | + ?bool $returnStoredSource = null, |
| 97 | + ?array $tracking = null, |
| 98 | + ): Collection { |
| 99 | + $results = $this->toBase()->search($operator, $index, $highlight, $concurrent, $count, $searchAfter, $searchBefore, $scoreDetails, $sort, $returnStoredSource, $tracking); |
76 | 100 |
|
77 | 101 | return $this->model->hydrate($results->all());
|
78 | 102 | }
|
|
0 commit comments