PHPackages                             nahid-ferdous/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. nahid-ferdous/laravel-searchable

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

nahid-ferdous/laravel-searchable
================================

Laravel Package To make Eloquent Queries Shorter.

1.4.0(2y ago)213.6k↓47.7%1[1 issues](https://github.com/nahidnfr123/laravel-searchable/issues)MITPHPPHP &gt;=7.4

Since Aug 9Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/nahidnfr123/laravel-searchable)[ Packagist](https://packagist.org/packages/nahid-ferdous/laravel-searchable)[ Docs](https://github.com/nahidnfr123/laravel-searchable)[ RSS](/packages/nahid-ferdous-laravel-searchable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (23)Used By (0)

Laravel Searchable Documentation
================================

[](#laravel-searchable-documentation)

Introduction
------------

[](#introduction)

### Overview

[](#overview)

Laravel Searchable is a powerful and flexible package that simplifies database searching in Laravel applications. It provides an elegant, fluent interface for building complex search queries across model attributes, relationships, and date ranges without writing verbose query builder code.

The package extends Laravel's Eloquent models with a convenient `search()` method that handles common search patterns like partial matching, relationship searching, concatenated field searches, and date filtering.

### Why Use Laravel Searchable?

[](#why-use-laravel-searchable)

**Clean and Readable Code**Transform complex search queries into simple, declarative syntax. Instead of writing multiple `where` and `orWhere` clauses, define your searchable fields in a straightforward array.

**Relationship Search Support**Seamlessly search across related models without manually writing `whereHas` queries. The package handles nested relationships automatically.

**Flexible Search Patterns**Support multiple search patterns out of the box:

- Exact matches
- Partial matches (LIKE queries)
- Concatenated field searches (e.g., first name + last name)
- Date and date range filtering
- Multiple search conditions

**Chainable and Composable**Chain multiple search methods together to build complex queries progressively. Combine text searches, status filters, and date ranges in any order.

**Zero Configuration**Get started immediately with sensible defaults, or publish the configuration file for advanced customization.

---

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require nahid-ferdous/laravel-searchable
```

---

Configuration
-------------

[](#configuration)

### Publishing the Configuration File

[](#publishing-the-configuration-file)

To customize the package behavior, publish the configuration file:

```
php artisan vendor:publish --provider="NahidFerdous\Searchable\SearchableServiceProvider"
```

This will create a `config/searchable.php` file where you can adjust package settings.

---

Setup
-----

[](#setup)

### Adding the Trait to Your Model

[](#adding-the-trait-to-your-model)

To make a model searchable, import and use the `Searchable` trait:

```
