generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't search on other fields then name #63
Comments
You can now add synonyms to your search dependencies as well. For example: <?php
namespace App\Spotlight;
use App\Models\User;
use LivewireUI\Spotlight\Spotlight;
use LivewireUI\Spotlight\SpotlightCommand;
use LivewireUI\Spotlight\SpotlightCommandDependencies;
use LivewireUI\Spotlight\SpotlightCommandDependency;
use LivewireUI\Spotlight\SpotlightSearchResult;
class ViewLicensee extends SpotlightCommand
{
protected string $name = 'View user';
public function dependencies(): ?SpotlightCommandDependencies
{
return SpotlightCommandDependencies::collection()
->add(
SpotlightCommandDependency::make('user')
->setPlaceholder('Which user do you want to view?')
);
}
public function searchUser($query)
{
return User::query()
->where('name', 'like', "%$query%")
->orWhere('email', 'like', "%$query%")
->take(10)
->get()
->map(function(User $user) {
return new SpotlightSearchResult(
$licensee->id,
$licensee->name,
sprintf('View %s', $user->name),
[
$licensee->email
]
);
});
}
public function execute(Spotlight $spotlight, User $user)
{
//
}
} |
Awesome! Thanks for your quick response and change |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If I have in my dependency a filter to search on name or email, I don't see any results in the spotlight if I search on the email address. I do see that the result is returned in the debug bar.
The text was updated successfully, but these errors were encountered: