Create a global search

Guys, what would be the best approach for me to take for the following resource. I need to create a screen for a global search. In the textobox I will enter the term and it will search in several models. The result must be grouped by model and must be displayed in a table. How should I do this? Thanks
10 Replies
krekas
krekas11mo ago
Why do you need it in a resource? What's wrong with the global search at the top nav?
joao nivaldo
joao nivaldoOP11mo ago
There is no way to search the table globally, as I will check several models and then return a result grouped by model. I think that in the global search of the table this cannot be done, if it is possible and you can show me how I appreciate it.
krekas
krekas11mo ago
can't you use this?
joao nivaldo
joao nivaldoOP11mo ago
So from what I saw, I can only use a Model with several relationships for this global search. And actually I need to search, for example, in the table, users, products, categories, blog, etc. And then return the result grouped by model.
krekas
krekas11mo ago
check the demo app isn't like that you want?
joao nivaldo
joao nivaldoOP11mo ago
According to the demo application, this would be the case. But I didn't understand how to do this from the documentation in the link you gave me. She only cites a record with several relationships. Or when I use this global search, does it already get all the columns that are marked for searches in the resource tables? Another thing, is there any way I can show the search results in a table and not in a dropdown? I've now read the documentation you gave me and I think I understand. I apologize for my questions. So I had 2 doubts. How do I disable a resource where I don't want it to be seen by global search and how can I show the result in a table, for example, or in another custom layout instead of the dropdown?
blntgvn42
blntgvn4211mo ago
in your resource, just put;
public static function getGloballySearchableAttributes(): array
{
return [];
}
public static function getGloballySearchableAttributes(): array
{
return [];
}
This disables global search for resource. However, I dont have any idea about custom layout 🙂
joao nivaldo
joao nivaldoOP11mo ago
Thanks for your help.
Dennis Koch
Dennis Koch11mo ago
I guess you could build your own page and just pass the search to the global search class and render the results yourself

Did you find this page helpful?