Global search for simple resources?

Is there a way of including simple resources in the global search? Possible a link to the list page with an extra parameter with the resource identifier and it automatically opens the modal.
11 Replies
Dan Harrin
Dan Harrin2y ago
There is not, as Livewire doesnt allow you to open modals when the page first loads unfortunately we can try again in v3
Husky110
Husky1102y ago
Stack Overflow
open modal automatically in livewire component it doesn't work
I wanna show a modal when initializing the component, but it doesn't work. I'm using $this->emit('show) to open the modal When I add a button in my view the emit('show') works!, but I don't want...
Husky110
Husky1102y ago
Like adding a view-component that does what is proposed in the SO-answer, which would then have to emit the show-action.
Dan Harrin
Dan Harrin2y ago
we use browser events to open modals.
Husky110
Husky1102y ago
So those modals are not triggerable somehow?
Dan Harrin
Dan Harrin2y ago
not on the page load, only after there are hacky workarounds but i dont want to muddy the codebase with those at the moment
Husky110
Husky1102y ago
Understandable.
benshawuk
benshawuk2y ago
I worked around this by linking the search result to the resource with a filter applied to single it out. I can share the code if you want? I’m not sure you’d want a modal opening directly from clicking on a result? This method works well for me.
gizmojo
gizmojoOP2y ago
Cheers guys appreciate all your input 🙂 Hopefully Dan can work his magic in v3. Yeah please that sounds like a good enough work around for now.
benshawuk
benshawuk2y ago
All on the resource ("companies" in my case):
// DB Field to get search result "title" from
protected static ?string $recordTitleAttribute = 'company_name';

// Searchable attributes
public static function getGloballySearchableAttributes(): array
{
return ['company_name'];
}

// URL
public static function getGlobalSearchResultUrl(Model $record) : ?string
{
return "/companies?tableSearchQuery=$record->company_name";
}

// DB Field to get search result "title" from
protected static ?string $recordTitleAttribute = 'company_name';

// Searchable attributes
public static function getGloballySearchableAttributes(): array
{
return ['company_name'];
}

// URL
public static function getGlobalSearchResultUrl(Model $record) : ?string
{
return "/companies?tableSearchQuery=$record->company_name";
}

gizmojo
gizmojoOP2y ago
Awesome cheers
Want results from more Discord servers?
Add your server