Laravel Searchable

v 1.4.*

Introduction

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?

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.

Requirements

  • PHP 7.4 or higher
  • Laravel 8.x, 9.x, 10.x, or 11.x