From 7dccd8599653f103b7945723bafb394d6d91e88e Mon Sep 17 00:00:00 2001 From: Daniel Stainback Date: Thu, 14 Dec 2023 14:45:30 -0500 Subject: [PATCH] Add options arg to search --- src/Concerns/Searching.php | 4 ++-- src/Contracts/Repository.php | 3 ++- src/Scopes/Search.php | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Concerns/Searching.php b/src/Concerns/Searching.php index 551fb2b..fa10b8a 100644 --- a/src/Concerns/Searching.php +++ b/src/Concerns/Searching.php @@ -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 = [ @@ -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'); } } diff --git a/src/Contracts/Repository.php b/src/Contracts/Repository.php index 81a7610..3f843bb 100644 --- a/src/Contracts/Repository.php +++ b/src/Contracts/Repository.php @@ -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 diff --git a/src/Scopes/Search.php b/src/Scopes/Search.php index 633c5f2..e6b3dee 100644 --- a/src/Scopes/Search.php +++ b/src/Scopes/Search.php @@ -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;