Skip to content

Commit

Permalink
Add options arg to search
Browse files Browse the repository at this point in the history
  • Loading branch information
Torann committed Dec 14, 2023
1 parent e861809 commit 7dccd85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Concerns/Searching.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getSearchable(): array
/**
* {@inheritDoc}
*/
public function search(string|array|null $queries): static
public function search(string|array|null $queries, array $options = []): static
{
if (is_string($queries)) {
$queries = [
Expand All @@ -89,7 +89,7 @@ public function search(string|array|null $queries): static
if (is_array($queries) && empty($queries) === false) {
/** @var Scope|null $scope */
if ($scope = $this->resolveScope('search')) {
$this->addScopeQuery($scope::make($queries), 'search');
$this->addScopeQuery($scope::make($queries, $options), 'search');
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Contracts/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ public function orderBy(mixed $column, string|null $direction): static;
* Filter results by given query params.
*
* @param string|array|null $queries
* @param array $options
*
* @return static
*/
public function search(string|array|null $queries): static;
public function search(string|array|null $queries, array $options = []): static;

/**
* Retrieve all data of repository
Expand Down
3 changes: 2 additions & 1 deletion src/Scopes/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ class Search extends Scope

/**
* @param array $queries
* @param array $options
*/
public function __construct(array $queries)
public function __construct(array $queries, array $options = [])
{
$this->queries = array_filter($queries, function ($value) {
return blank($value) === false;
Expand Down

0 comments on commit 7dccd85

Please sign in to comment.