dvictor357/laravel-omnisearch
最新稳定版本:1.0.0
Composer 安装命令:
composer require dvictor357/laravel-omnisearch
包简介
A global command palette (Cmd+K) for Laravel applications. Search models, navigate routes, and execute commands from anywhere.
README 文档
README
A global command palette (Cmd+K / Ctrl+K) for Laravel 11/12 applications. Search models, navigate routes, and execute commands from anywhere.
Features
- 🔍 Global Search – Search across models, routes, and commands
- ⌨️ Keyboard-First – Full keyboard navigation (
↑,↓,Enter,Esc) - 🎨 Premium UI – Glassmorphism design that looks beautiful out of the box
- 🔌 Extensible – Easy to add custom search sources
- ⚡ Livewire 3 – Real-time search powered by Livewire
Requirements
- PHP 8.2+
- Laravel 11.x or 12.x
- Livewire 3.x
Installation
composer require dvictor357/laravel-omnisearch
Publish the config file (optional):
php artisan vendor:publish --tag=omnisearch-config
Add the component to your main layout (before </body>):
<livewire:omnisearch />
Configuration
Searchable Models
Configure which models should be searchable in config/omnisearch.php:
'models' => [ App\Models\User::class => [ 'columns' => ['name', 'email'], // Columns to search 'title' => 'name', // Display title 'description' => 'email', // Display subtitle 'route' => 'users.show', // Named route (receives model ID) 'icon' => 'user', // Icon identifier 'limit' => 5, // Max results for this model ], ],
Route Filtering
Control which routes appear in search:
'routes' => [ 'include' => ['*'], 'exclude' => ['api.*', 'sanctum.*', 'livewire.*'], ],
UI Customization
'ui' => [ 'placeholder' => 'Search anything...', 'debounce' => 300, 'max_results' => 10, 'show_keyboard_hints' => true, ],
Creating Custom Sources
Implement the SearchSource interface:
use OmniSearch\Contracts\SearchSource; use OmniSearch\Data\Result; class MyCustomSource implements SearchSource { public function getKey(): string { return 'custom'; } public function getLabel(): string { return 'My Results'; } public function getIcon(): string { return 'star'; } public function authorize(): bool { return auth()->check(); } public function search(string $query): Collection { return collect([ Result::navigate( id: 'custom:1', title: 'Custom Item', description: 'A custom search result', url: '/custom/1', icon: 'star', group: $this->getLabel(), ), ]); } }
Register in config/omnisearch.php:
'sources' => [ OmniSearch\Sources\ModelSource::class, OmniSearch\Sources\RouteSource::class, App\Search\MyCustomSource::class, // Add your source ],
License
MIT
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-31
