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)035MITPHPPHP ~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 1mo ago

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

25

—

LowBetter than 37% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

567d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7080d68b08c41a268daab0de9e121cd06f79925fdb11b696be38d7ea3fbb170?d=identicon)[vits](/maintainers/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

[algolia/scout-extended

Scout Extended extends Laravel Scout adding algolia-specific features

4186.3M6](/packages/algolia-scout-extended)[swisnl/laravel-fulltext

Fulltext indexing and searching for Laravel

184104.5k6](/packages/swisnl-laravel-fulltext)[kyslik/laravel-filterable

Using URL query strings to filter Eloquent queries.

11539.0k](/packages/kyslik-laravel-filterable)[devnoiseconsulting/laravel-scout-postgres-tsvector

PostgreSQL Full Text Search Driver for Laravel Scout

58110.1k](/packages/devnoiseconsulting-laravel-scout-postgres-tsvector)[vanry/laravel-scout-tntsearch

包含中文分词的 Laravel Scout TNTSearch 驱动，支持 scws, phpanalysis 和 jieba 分词。

17811.8k1](/packages/vanry-laravel-scout-tntsearch)[gtk/larasearch

A driver based solution to searching your Eloquent models supports Laravel 5.2 and Elasticsearch engine.

133.9k](/packages/gtk-larasearch)

PHPackages © 2026

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