hetparekh21 / searchable
Add simple search functionality to any model
Installs: 42
Dependents: 0
Suggesters: 0
Security: 0
Stars: 10
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/hetparekh21/searchable
Requires
- php: >=8.1
 
This package is auto-updated.
Last update: 2025-10-29 03:12:23 UTC
README
Effortlessly add search functionality to your Laravel models.
Installation
- Install the package via Composer:
 
composer require hetparekh21/searchable
Usage
- Use the 
Searchabletrait in your model: 
use hetparekh21\searchable\Searchable; class User extends Model { use Searchable; protected $fillable = [ 'first_name', 'last_name', 'email', 'phone' ]; protected $guarded = ['id']; protected $except = ['phone']; protected $useGuarded = false; }
- Perform searches using the 
scopeSearchmethod: 
$users = User::search('John Doe')->get();
- Search Paginated, As easy as laravel default queries
 
$users = User::search('John Doe')->paginate(10);
Configuration
exceptproperty: Exclude specific columns from the search (optional).useGuardedproperty: Include guarded attributes in the search (optional).
Contributing
Anyone is welcome to contribute. Fork, make your changes, and then submit a pull request.
License
Searchable is open-sourced software licensed under the MIT license: LICENSE.