sqits / laravel-searchable
Package to add an easy way to add a basic search functionality to your models
Requires
- php: ^7.3|^8.0
- laravel/framework: ^5.6|^6.0|^7.0|^8.0
Requires (Dev)
- doctrine/dbal: ^3.1
- larapack/dd: ^1.1
- orchestra/testbench: ^6.19
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-07 13:54:52 UTC
README
Provides an Eloquent trait to add to your models to integrate an easy way to search in your model and relations.
Installation and usage
This package requires PHP 7.3 and Laravel 5.6 or higher. Install the package by running the following command in your console;
composer require sqits/laravel-searchable
You can publish the config file with:
php artisan vendor:publish --provider="Sqits\Searchable\SearchableServiceProvider" --tag="config"
This is the contents of the published config file:
return [ /* * Define the parameter in your request which contains the search values */ 'parameter' => 'search', ];
Add the Trait to your model
use Sqits\Searchable\Traits\HasSearchable; class Example extends Model { use HasSearchable; }
Add the configuration to your model which fields are searchable
// In the examples we are using `like`, but every value which you could use in eloquent are usable eg '=', '=>', '<=', '>', '<' etc. // simple field protected $searchables = [ 'name' => 'like', ]; // combined fields protected $searchables = [ 'name' => [ 'first_name' => 'like', 'last_name' => 'like', ], ];
Changelog
Please see CHANGELOG for more information what has changed recently.
Security
If you discover any security-related issues, please email to info@sqits.nl instead of using the issue tracker.
Credits
upda
License
The MIT License (MIT). Please see License File for more information.