PHPackages                             sqits/laravel-searchable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. sqits/laravel-searchable

ActiveLibrary[Search &amp; Filtering](/categories/search)

sqits/laravel-searchable
========================

Package to add an easy way to add a basic search functionality to your models

00PHP

Since Jul 6Pushed 4y ago1 watchersCompare

[ Source](https://github.com/sqits/laravel-searchable)[ Packagist](https://packagist.org/packages/sqits/laravel-searchable)[ RSS](/packages/sqits-laravel-searchable/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Package to add an easy way to add a basic search functionality to your models
=============================================================================

[](#package-to-add-an-easy-way-to-add-a-basic-search-functionality-to-your-models)

Provides an Eloquent trait to add to your models to integrate an easy way to search in your model and relations.

[![Latest Version on Packagist](https://camo.githubusercontent.com/67629ae46d261e129fcf213bc15b6644366be457b2af652126daa2e0a5fb2eba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73716974732f6c61726176656c2d73656172636861626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sqits/laravel-searchable)[![Build Status](https://camo.githubusercontent.com/cca16a24cd3f87bf5a6a9391f5ee2a93df9b8a6d0e9ea8a748bf7512e3d8bfff/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f73716974732f6c61726176656c2d73656172636861626c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/sqits/laravel-searchable)[![Quality Score](https://camo.githubusercontent.com/d2e4871928467321b9b40e05c5fe93fa230ac54872ab8269610b7c3ae4aed158/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f73716974732f6c61726176656c2d73656172636861626c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/sqits/laravel-searchable)[![StyleCI](https://camo.githubusercontent.com/ea9bacbccfb9fb165745dcd43840c41d05c81180cd3c1ce4214bb7cc074f393e/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3138303831363635392f736869656c64)](https://styleci.io/repos/180816659)[![Total Downloads](https://camo.githubusercontent.com/1968f8a1e8310ae6fd4af10985a3d953d6b60a0dc2772919f3634905e787a8dd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73716974732f6c61726176656c2d73656172636861626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sqits/laravel-searchable)

Installation and usage
----------------------

[](#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 '=', '=>', '', '
