chrisreedio / laravel-scout-keys
Provides user level tenant tokens / scoped search keys.
Fund package maintenance!
Chris Reed
Requires
- php: ^8.2
- http-interop/http-factory-guzzle: ^1.2
- illuminate/contracts: ^10.0||^11.0
- laravel/scout: ^10.11
- meilisearch/meilisearch-php: ^1.10
- spatie/laravel-package-tools: ^1.16
- typesense/typesense-php: ^4.9
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^2.34
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-laravel: ^2.3
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2024-12-02 19:52:24 UTC
README
This package provides user level tenant tokens / scoped search keys for Laravel Scout.
The current implementation supports the Meilisearch and Typesense drivers.
TODO
- Add support for runtime configuration of generated key facets/filtered attributes
Installation
You can install the package via composer:
composer require chrisreedio/laravel-scout-keys
You can publish and run the migrations with:
php artisan vendor:publish --tag="laravel-scout-keys-migrations"
php artisan migrate
You can publish the config file with:
php artisan vendor:publish --tag="laravel-scout-keys-config"
This is the contents of the published config file:
return [ /** * Whether to register the Scout Indexing commands for use via web. */ 'register_commands' => false, 'key' => [ /** * The number of minutes a search key should be valid for. */ 'lifetime' => env('SCOUT_KEY_EXPIRATION', 60 * 12), ], ];
Usage
Add the SearchUser
interface and HasSearchKeys
trait to your User
model(s).
Example:
class User extends Authenticatable SearchUser { use HasFactory, HasSearchKeys; // ... }
Finally, add the following to your web.php
routes file:
ScoutKeys::getRoute();
If you'd like to change the default path of /search/key
, you may pass the desired path as the first argument to the getRoute
method.
ScoutKeys::getRoute('dashboard/search/key');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.