Confusing Attributes in getSearchResults Method For Select From Field

I came across this code in filament v3
public function getSearchResults(string $search): array
{
    if (! $this->getSearchResultsUsing) {
        return [];
    }

    $results = $this->evaluate($this->getSearchResultsUsing, [
        'query' => $search,
        'search' => $search,
        'searchQuery' => $search,
    ]);

    if ($results instanceof Arrayable) {
        $results = $results->toArray();
    }

    return $results;
}


My question is why the query and search and searchQuery keys in the evaluate method have value of $search? this is confusing especially when I use query I expected a query builder not a search value. its need some refactoring on the values side or on the keys side of the array. Any suggestion or explanation for this part? I would suggest to make it look like this
public function getSearchResults(string $search): array
{
    if (! $this->getSearchResultsUsing) {
        return [];
    }

    $relationship = Relation::noConstraints(fn() => $this->getRelationship());

    $relationshipQuery = app(RelationshipJoiner::class)->prepareQueryForNoConstraints($relationship);

    $results = $this->evaluate($this->getSearchResultsUsing, [
        'query' => $relationshipQuery,
        'search' => $search,
    ]);

    if ($results instanceof Arrayable) {
        $results = $results->toArray();
    }

    return $results;
}
Solution
I would suggest to make it look like this
You can implement this in your code, right? I don't think the change will happen because it's a breaking change.
Was this page helpful?