> For the complete documentation index, see [llms.txt](https://helpdocs.quickadminpanel.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://helpdocs.quickadminpanel.com/modules/global-search.md).

# Global Search

First, a quick video demo of the module.

{% embed url="<https://www.youtube.com/watch?v=f0tm2TaDVW0>" %}

## How does it work?&#x20;

After installing the module, you can enable any individual **field** in any CRUD to be "searchable":&#x20;

![](/files/-MAFJ7gn0QVXsuCpxoRM)

And then, in the generated panel, in top-left corner, you will see a search field, which, after you type in at least 3 characters, will look for all records in all CRUDs/Fields you specified:

![](/files/-MAFKH-7diOAU0-iiNGR)

## Customization

If you want to customize the behavior of Global Search, it's all in the generated file **app/Http/Controllers/Admin/GlobalSearchController.php**, here's the main method:

```
    public function search(Request $request)
    {
        $search = $request->input('search');

        if ($search === null || !isset($search['term'])) {
            abort(400);
        }

        $term           = $search['term'];
        $searchableData = [];

        foreach ($this->models as $model => $translation) {
            $modelClass = 'App\\' . $model;
            $query      = $modelClass::query();

            $fields = $modelClass::$searchable;

            foreach ($fields as $field) {
                $query->orWhere($field, 'LIKE', '%' . $term . '%');
            }

            $results = $query->take(10)
                ->get();

            foreach ($results as $result) {
                $parsedData           = $result->only($fields);
                $parsedData['model']  = trans($translation);
                $parsedData['fields'] = $fields;
                $formattedFields      = [];

                foreach ($fields as $field) {
                    $formattedFields[$field] = Str::title(str_replace('_', ' ', $field));
                }

                $parsedData['fields_formated'] = $formattedFields;

                $parsedData['url'] = url('/admin/' . Str::plural(Str::snake($model, '-')) . '/' . $result->id . '/edit');

                $searchableData[] = $parsedData;
            }
        }

        return response()->json(['results' => $searchableData]);
    }
```

So if, for example, you want the default click to lead to SHOW method instead of default EDIT, you need to change this line:

```
$parsedData['url'] = url('/admin/' . Str::plural(Str::snake($model, '-')) . '/' . $result->id . '/edit');
```
