Replies: 6 comments
-
I haven't tested this but you could try: public function shouldBeShown(Request $request): bool
{
if($request->route('project')) {
return true;
}
return false;
} |
Beta Was this translation helpful? Give feedback.
-
Sweet, I changed it to |
Beta Was this translation helpful? Give feedback.
-
One more question. Can I reach I'm trying to do something like this: public function execute(Spotlight $spotlight, Request $request)
{
$spotlight->emit('openModal', 'create-post', ['projectId' => basename($request->path()]);
}
public function shouldBeShown(Request $request): bool
{
if ($request->routeIs('project')) {
return true;
}
} |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, that will not work. The public function shouldBeShown(Request $request): bool
{
if ($request->routeIs('project')) {
session()->flash('productId', $request->route('project')->id);
return true;
}
}
public function execute(Spotlight $spotlight, Request $request)
{
$spotlight->emit('openModal', 'create-post', ['projectId' => session('projectId')));
} |
Beta Was this translation helpful? Give feedback.
-
Cool thanks!! It seems like So setting the session there only works first time for me. I could change from flash to a persistent session, but then I need to figure out how to remove it when I'm done which gets a little messy since sometimes you go all the way to execute and sometimes cancel out early. Let me know if you can think of something :) Huge thanks again. |
Beta Was this translation helpful? Give feedback.
-
This worked, but kinda ugly hehe :) Welcome to my brain lol. public function shouldBeShown(Request $request): bool
{
if ($request->routeIs('project')) {
session(['projectId' => basename($request->path())]);
} else {
if ($request->route()->getName() != 'livewire.message') {
session()->forget('projectId');
}
}
return true;
} |
Beta Was this translation helpful? Give feedback.
-
Is there any way to tell Spotlight what the page component is and cater the behavior to that?
An example. If I open Spotlight on my dashboard and type "New post" it should ask me what project I want to create the post for - great, but if I'm already inside a project, can this info be pre-populated somehow? E.g. can I tell Spotlight that it was opened on a project page and now assume that you want to create the post for that project?
Thanks!
Edit // When I think about it. I may even have some options that should only show up in Spotlight if it's called from a certain component. Either way, I think both ways would be solved if I could tell Spotlight where it was called from. Maybe this is already possible?
Beta Was this translation helpful? Give feedback.
All reactions