Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add builder as a parameter for search callback
If a callback is used when searching (ex: Model::search('term', function (...args) { closure })) there is an error, "Too few arguments to function {closure}(), 3 passed and exactly 4 expected".

$builder->callback is the closure itself. Next it is expecting the builder but is receiving $documents.
  • Loading branch information
kdevan authored Oct 19, 2021
commit 2b6ea3c34e9b5f61dd00b1d5c7a4e18e7a9d526f
2 changes: 1 addition & 1 deletion src/Engines/TypesenseSearchEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ protected function performSearch(Builder $builder, array $options = []): mixed
$documents = $this->typesense->getCollectionIndex($builder->model)
->getDocuments();
if ($builder->callback) {
return call_user_func($builder->callback, $documents, $builder->query, $options);
return call_user_func($builder->callback, $builder, $documents, $builder->query, $options);
}

return $documents->search($options);
Expand Down