Skip to content

Conversation

@devsquad-pedro-silva
Copy link
Contributor

Allow where in using an array or a collection

For situations that have HasMany relationship or BelongToMany, such as a User that has many roles, and it is necessary to search for users by the role name, the searchableArray method is defined like this:

public function toSearchableArray(): array
{
    return [
     ...
        ‘roles’ => $this->roles->pluck(‘name’),
     ...
    ];
}

or

public function toSearchableArray(): array
{
   return [
   ...
       ‘roles’ => $this->roles->pluck(‘name’)->toArray(),
   ...
   ];
}

has the same goal as #26, but including collection comparison

@devsquad-pedro-silva
Copy link
Contributor Author

@Sti3bas please let me know if you have any feedback on this!

@Sti3bas Sti3bas merged commit af6115e into Sti3bas:master Aug 4, 2025
18 checks passed
@Sti3bas
Copy link
Owner

Sti3bas commented Aug 4, 2025

@devsquad-pedro-silva sorry for the delay and thank you!

Released in https://github.com/Sti3bas/laravel-scout-array-driver/releases/tag/v4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants