Skip to content

Commit a7177ed

Browse files
committed
Fix Eloquent Builder signature
1 parent 71fd529 commit a7177ed

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

src/Eloquent/Builder.php

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
namespace MongoDB\Laravel\Eloquent;
66

77
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
8+
use Illuminate\Database\Eloquent\Collection;
9+
use Illuminate\Database\Eloquent\Model;
810
use MongoDB\BSON\Document;
11+
use MongoDB\Builder\Type\SearchOperatorInterface;
912
use MongoDB\Driver\CursorInterface;
1013
use MongoDB\Driver\Exception\WriteException;
1114
use MongoDB\Laravel\Connection;
@@ -21,7 +24,10 @@
2124
use function iterator_to_array;
2225
use function property_exists;
2326

24-
/** @method \MongoDB\Laravel\Query\Builder toBase() */
27+
/**
28+
* @method \MongoDB\Laravel\Query\Builder toBase()
29+
* @template TModel of Model
30+
*/
2531
class Builder extends EloquentBuilder
2632
{
2733
private const DUPLICATE_KEY_ERROR = 11000;
@@ -70,9 +76,27 @@ public function aggregate($function = null, $columns = ['*'])
7076
return $result ?: $this;
7177
}
7278

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);
76100

77101
return $this->model->hydrate($results->all());
78102
}

0 commit comments

Comments
 (0)