- How do I install Scoutify in a Laravel 12 project with Livewire 4?
- Run `composer require matheusmarnt/scoutify` and publish the config with `php artisan scoutify:install`. Ensure you have Livewire 4 installed (`composer require livewire/livewire`) and a Scout driver configured (e.g., Meilisearch). The package auto-detects models under `app/Models/` using the `Searchable` trait.
- Can Scoutify work with the Scout database driver instead of Meilisearch/Algolia?
- Yes, but expect performance trade-offs for infix searches. The database driver is viable for small-scale projects or simple queries, but Meilisearch/Algolia/Typesense are recommended for production workloads. Test query latency with your dataset before committing to the database driver.
- How do I customize the search modal’s appearance or behavior?
- Scoutify uses Tailwind CSS for styling, so override classes in your global CSS or publish the views with `php artisan vendor:publish --tag=scoutify-views`. For behavior, use the `globalSearchBuilder` and `globalSearchVisibility` hooks in the config to modify queries or visibility rules.
- Does Scoutify support role-based access control (RBAC) for search results?
- Yes, via Spatie’s Permission package (optional). If you don’t use Spatie, implement custom gates in the `globalSearchVisibility` closure. The package checks permissions per-model by default, but you can adjust granularity in the config.
- What Laravel Scout versions does Scoutify support?
- Scoutify is compatible with Laravel Scout 11 and 12, which align with Laravel 11/12/13. Ensure your Scout driver (e.g., Meilisearch) is also up-to-date. The package leverages Scout’s core features like `Searchable` traits and `toSearchableArray()`, so no additional Scout-specific dependencies are required.
- How do I handle file previews (e.g., images, PDFs) in search results?
- Use the `HasGlobalSearchPreview` trait on your models. Scoutify generates temporary URLs via the `scoutify:download` event. For large files, ensure your storage backend (e.g., S3) supports streaming and configure the `preview_url` method in your model to return a valid URL.
- Will Scoutify work with a dynamic layout where the modal might conflict with other modals?
- The modal must be placed at the root layout level to ensure keyboard triggers (⌘K/Ctrl+K) work correctly. If your layout uses dynamic sidebars or nested modals, test thoroughly to avoid duplicate triggers. You can hide the modal conditionally using the `globalSearchVisibility` hook.
- How do I reindex Scout data when schema changes occur?
- Use the `scoutify:import` artisan command to reindex all searchable models. For CI/CD pipelines, run this command after migrations or schema updates. Scoutify integrates with Scout’s existing reindexing logic, so no additional setup is needed beyond your existing Scout configuration.
- Are there alternatives to Scoutify for Laravel global search?
- Yes, alternatives include Laravel Scout’s built-in search (limited to single-model queries), Laravel Nova’s search, or custom Livewire/Alpine.js solutions. Scoutify stands out by combining Scout’s power with a multi-model Livewire UI, auto-discovery, and session-based history—ideal for production apps needing ⌘K shortcuts.
- How do I test Scoutify in a CI environment with headless browsers?
- Use Laravel’s `Livewire::test()` methods or PestPHP’s Livewire assertions to test the modal’s keyboard interactions and search results. Mock Scout queries with `Scout::fake()` to avoid hitting external search engines. Test the ⌘K/Ctrl+K trigger with `browser()->keyboard()->press('command+k')` (or `control+k` for non-Mac).