wire-elements / spotlight

Livewire component that brings Spotlight/Alfred-like functionality to your Laravel application.
MIT License
912 stars 71 forks source link

Get input value as string #65

Closed cloudstudio closed 2 years ago

cloudstudio commented 2 years ago

Hey @PhiloNL hope you have a good day.

I have created a timetracker in livewire, why not use spotlight? just for fun :)

After creating the project, it asks me the name of the task, is there any way to get this string directly? The idea is to be able to create a new task.

`

public function dependencies(): ?SpotlightCommandDependencies
{
    return SpotlightCommandDependencies::collection()
        ->add(
            SpotlightCommandDependency::make('project')
            ->setPlaceholder('Choose project')
        )->add(
            SpotlightCommandDependency::make('task')
            ->setPlaceholder('Task name')
        );
}

public function searchProject($query)
{
    return Project::where('name', 'like', "%$query%")
        ->get()
        ->map(function(Project $project) {
            return new SpotlightSearchResult(
                $project->id,
                $project->name,
                sprintf('Create task for %s', $project->name)
            );
        });
}

public function searchTask($query, Project $project)
{
   // HOW I CAN RETURN THIS QUERY???? FOR EXAMPLE "DESIGN"
}

public function execute(Spotlight $spotlight, Project $project)
{
    // Yes we are here!! now I want create a new task with previous string Design
}

`

I don't know if it is possible to do this :) thanks for you time !

https://user-images.githubusercontent.com/3589377/144456381-2ee8fc96-3d44-49d0-925b-2b265f01f601.mov

PhiloNL commented 2 years ago

Set the dependency type to input 😄

add(SpotlightCommandDependency::make('foobar')->setPlaceholder('Input from user')->setType(SpotlightCommandDependency::INPUT));
cloudstudio commented 2 years ago

lol I didn't see that, thanks buddy!