LaravelPackages.net
Acme Inc.
Toggle sidebar
hetparekh21/searchable

Add simple search functionality to any model

42
10
1.0.0
About hetparekh21/searchable

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

hetparekh21/Searchable

Effortlessly add search functionality to your Laravel models.

Installation

  1. Install the package via Composer:
composer require hetparekh21/searchable

Usage

  1. Use the 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;

}
  1. Perform searches using the scopeSearch method:
$users = User::search('John Doe')->get();
  1. Search Paginated, As easy as laravel default queries
$users = User::search('John Doe')->paginate(10);

Configuration

  • except property: Exclude specific columns from the search (optional).
  • useGuarded property: 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.

Comments