Skip to content

Commit cdd7c53

Browse files
committed
Fix Eloquent Builder signature
1 parent 132a773 commit cdd7c53

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

src/Eloquent/Builder.php

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
88
use MongoDB\BSON\Document;
9+
use MongoDB\Builder\Type\SearchOperatorInterface;
910
use MongoDB\Driver\CursorInterface;
1011
use MongoDB\Driver\Exception\WriteException;
1112
use MongoDB\Laravel\Connection;
@@ -70,9 +71,38 @@ public function aggregate($function = null, $columns = ['*'])
7071
return $result ?: $this;
7172
}
7273

73-
public function search(...$args)
74-
{
75-
$results = $this->toBase()->search(...$args);
74+
/**
75+
* Performs a full-text search of the field or fields in an Atlas collection.
76+
* NOTE: $search is only available for MongoDB Atlas clusters, and is not available for self-managed deployments.
77+
*
78+
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/search/
79+
*
80+
* @param SearchOperatorInterface|array $operator Operator to search with. You can provide a specific operator or use the compound operator to run a compound query with multiple operators.
81+
* @param ?string $index Name of the Atlas Search index to use. If omitted, defaults to "default".
82+
* @param ?array $highlight Specifies the highlighting options for displaying search terms in their original context.
83+
* @param ?bool $concurrent Parallelize search across segments on dedicated search nodes.
84+
* @param ?string $count Document that specifies the count options for retrieving a count of the results.
85+
* @param ?string $searchAfter Reference point for retrieving results. searchAfter returns documents starting immediately following the specified reference point.
86+
* @param ?string $searchBefore Reference point for retrieving results. searchBefore returns documents starting immediately before the specified reference point.
87+
* @param ?bool $scoreDetails Flag that specifies whether to retrieve a detailed breakdown of the score for the documents in the results. If omitted, defaults to false.
88+
* @param ?array $sort Document that specifies the fields to sort the Atlas Search results by in ascending or descending order.
89+
* @param ?bool $returnStoredSource Flag that specifies whether to perform a full document lookup on the backend database or return only stored source fields directly from Atlas Search.
90+
* @param ?array $tracking Document that specifies the tracking option to retrieve analytics information on the search terms.
91+
*/
92+
public function search(
93+
SearchOperatorInterface|array $operator,
94+
?string $index = null,
95+
?array $highlight = null,
96+
?bool $concurrent = null,
97+
?string $count = null,
98+
?string $searchAfter = null,
99+
?string $searchBefore = null,
100+
?bool $scoreDetails = null,
101+
?array $sort = null,
102+
?bool $returnStoredSource = null,
103+
?array $tracking = null,
104+
) {
105+
$results = $this->toBase()->search($operator, $index, $highlight, $concurrent, $count, $searchAfter, $searchBefore, $scoreDetails, $sort, $returnStoredSource, $tracking);
76106

77107
return $this->model->hydrate($results->all());
78108
}

0 commit comments

Comments
 (0)