Skip to content

Commit

Permalink
fix: Fixing query matches. (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
binaryk authored Nov 25, 2021
1 parent 7534c1d commit 883d60b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
7 changes: 7 additions & 0 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
'related' => \Binaryk\LaravelRestify\Repositories\Casts\RelatedCast::class,
],

'search' => [
/*
| Allow Restify to check the post payload in order to receive matchable filters.
*/
'matchable_using_post_payload' => true,
],

/*
|--------------------------------------------------------------------------
| Restify Logs
Expand Down
11 changes: 8 additions & 3 deletions src/Filters/MatchesCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public function inQuery(RestifyRequest $request): self
{
return $this->filter(function (MatchFilter $filter) use ($request) {
$possibleKeys = collect([
$filter->getColumn(),
"-{$filter->getColumn()}",
$filter->column(),
"-{$filter->column()}",
]);

if ($filters = collect($request->input('filter', []))) {
Expand All @@ -60,7 +60,12 @@ public function inQuery(RestifyRequest $request): self
}
}

return $request->has("-{$filter->getColumn()}") || $request->has($filter->getColumn());
if (! config('restify.search.matchable_using_post_payload')) {
return (bool) ($request->query("-{$filter->column()}") || $request->query($filter->column()));
}


return $request->has("-{$filter->column()}") || $request->has($filter->column());
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/ActionRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function builder(Action $action, int $size): Builder
->latest($this->model()->getKeyName());
}

public function collectRepositories(Action $action, $count, Closure $callback)
public function collectRepositories(Action $action, $count, Closure $callback): array
{
$output = [];

Expand Down

0 comments on commit 883d60b

Please sign in to comment.