therecluse26/laravel-scout-tools

Tools and enhancements for Laravel Scout

dev-main 2023-05-22 18:21 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Installation

You can install the package via composer:

composer require therecluse26/laravel-scout-tools

You can publish all custom resources with:

php artisan vendor:publish --provider="TheRecluse26\ScoutTools\ScoutToolsServiceProvider"
php artisan migrate

This will generate a migration file and a config/scout-tools.php file with the following contents:

(This config can be individually be generated using php artisan vendor:publish --tag="scout-tools-config")

return [
	'driver' => env('SCOUT_DRIVER'),
	'routes' => [
		'middleware' => ['auth:api'],
		'endpoints' => [
			'get-models' => ['path' => '/scout/models'],
			'refresh-models' => ['path' => '/scout/models/refresh'],
			'index-detail' => ['path' => '/scout/index/{scout_model}'],
		],
	],
];

This can be modified to specify custom route paths well as which middleware(s) to apply to the route group

Views

Optionally, you can publish Vue templates to /resources/assets/js/scout-tools using

php artisan vendor:publish --tag="scout-tools-vue"

You can also publish Blade components using (these will be published to app/View/Components/Scout)

 php artisan scout-tools:install-view ScoutModelTable
 php artisan scout-tools:install-view ScoutModelTableRow

Usage

This package provides some useful functionality missing from the base Laravel Scout package

Artisan Commands

This package exposes a php artisan scout:sync command that can be used to automatically detect all project models with the Scout Searchable trait and synchronize their data with the configured Scout service.

Passing a --flush or -F flag to this command will clear the Scout index data and re-sync it all from scratch.

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.