PHPackages                             vits/laravel-simple-search - 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. vits/laravel-simple-search

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

vits/laravel-simple-search
==========================

Simple search scope for Laravel models.

0.1(1y ago)038MITPHPPHP ~8.2

Since Oct 22Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Simple search scope for Laravel models
======================================

[](#simple-search-scope-for-laravel-models)

Search for words in one or more text fields (`string` or `text`) using provided search strategies.

Search query string is split into words and each of these words must match at least one of given fields. Each field may have different search strategy.

**NB: Some of search strategies may work only with MySQL database driver.**

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

[](#installation)

```
composer require vits/laravel-simple-search
```

Usage
-----

[](#usage)

`SimpleSearch` model trait adds `simpleSearch` scope. Scope accepts search query string and optional list of fields to be searched. Searched fields and default search strategy may also be configured as model properties.

```
use Vits\LaravelSimpleSearch\SimpleSearch;
use Vits\LaravelSimpleSearch\SimpleSearchStrategy;

class Book extends Model
{
    use SimpleSearch;

    protected $simpleSearchStrategy = SimpleSearchStrategy::IN_WORDS;
    protected $simpleSearchFields = 'title,body';
}
```

```
$books = Book::simpleSearch('alice', 'title,body')->get();
```

### Available search strategies

[](#available-search-strategies)

`SimpleSearch::EXACT` - field value must be exact match of search string.

`SimpleSearch::IN_WORDS` - field must contain search string anywhere in it.

`SimpleSearch::START_OF_WORDS` - field must contain word starting with search string. This ir default strategy.

`SimpleSearch::START_OF_STRING` - field value must start with search string.

### Different ways to define searched fields

[](#different-ways-to-define-searched-fields)

This may be used both in `simpleSearch` scope and as model property.

If field definition does not assign search strategy, value of model property `simpleSearchStategy` is used as default strategy. If not set, `SimpleSearch::START_OF_WORDS` is default search strategy.

```
# single field
protected $simpleSearchFields = 'title';
# multiple fields
protected $simpleSearchFields = 'alice', 'title,description';
# multiple fields as array
protected $simpleSearchFields = 'alice', ['title', 'description'];
# multiple fields as array with strategy
protected $simpleSearchFields = 'alice', [
    'title',
    'description',
    'notes' => SimpleSearchStrategy::IN_WORD
];
```

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

619d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22852?v=4)[Vitauts Stočka](/maintainers/vits)[@vits](https://github.com/vits)

---

Top Contributors

[![vits](https://avatars.githubusercontent.com/u/22852?v=4)](https://github.com/vits "vits (2 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/vits-laravel-simple-search/health.svg)

```
[![Health](https://phpackages.com/badges/vits-laravel-simple-search/health.svg)](https://phpackages.com/packages/vits-laravel-simple-search)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4196.7M6](/packages/algolia-scout-extended)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[api-platform/laravel

API Platform support for Laravel

58171.4k14](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
