hetparekh21/searchable is a Laravel package for add simple search functionality to any model.
It currently has 10 GitHub stars and 42 downloads on Packagist (latest version 1.0.0).
Install it with composer require hetparekh21/searchable.
Discover more Laravel packages by hetparekh21
or browse all Laravel packages to compare alternatives.
Last updated
Effortlessly add search functionality to your Laravel models.
composer require hetparekh21/searchable
Searchable trait 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;
}
scopeSearch method:$users = User::search('John Doe')->get();
$users = User::search('John Doe')->paginate(10);
except property: Exclude specific columns from the search (optional).useGuarded property: Include guarded attributes in the search (optional).Anyone is welcome to contribute. Fork, make your changes, and then submit a pull request.
Searchable is open-sourced software licensed under the MIT license: LICENSE.