GlobalSearchController and register Vue components for search results.
Configuring GlobalSearchController
The GlobalSearchController allows you to register models that can be searched.
Location
The controller file is located at:Example Code
Here is the default implementation of the controller:Adding New Models to Search
To add new models to the global search, use theGlobalSearch::registerModel method. For example:
Post::class with the name of your model and specify the attributes to include in the search.
Registering Vue Components for Search Results
After setting up the controller, register Vue components to display the search results.Location
Register Vue components in:Example Registration
Add your component to theglobalSearchComponents section:
Example Vue Component
Below is an example Vue component for displaying search results. Use theLink component from Inertia.js to link to the resource.
Adding New Vue Components
To add a new Vue component:- Create a new Vue file in the appropriate folder (e.g.,
resources/js/components). - Follow the example structure above.
- Register the component in
app.js.
Final Notes
- Ensure that your models and Vue components are properly linked.
- Test your implementation by performing a search.