PHPackages                             vaened/laravel-criteria - 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. vaened/laravel-criteria

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

vaened/laravel-criteria
=======================

Search engine builder for eloquent

v2.0.5(4mo ago)1125.3k—0.6%MITPHPPHP ^8.2CI passing

Since May 18Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/vaened/laravel-criteria)[ Packagist](https://packagist.org/packages/vaened/laravel-criteria)[ RSS](/packages/vaened-laravel-criteria/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (7)Versions (14)Used By (0)

Laravel Criteria
================

[](#laravel-criteria)

Search engine builder for eloquent

```
composer require vaened/laravel-criteria
```

Usage
-----

[](#usage)

Turns a php class into a powerful, readable and friendly [`Query Builder`](./tests/Utils/Searcher.php).

```
use Flagable, Indexed;

public function __construct(
    private readonly IndexRepository $index,
    private readonly FlagFiltrator   $filter
) {
    $this->apply(Criterias\PatientDeletionDate::without());
}

public function affiliatedBetween(DateTimeInterface $start, DateTimeInterface $end): self
{
    $this->apply(Criterias\PatientAffiliation::between($start, $end));
}

public function observationLikeTo(string $observation): self
{
    $this->apply(Criterias\PatientObservation::startsWith($observation));
}

public function onlyObserved(): self
{
    $this->apply(Criterias\PatientObservation::isNotNull());
}

public function withoutObservation(): self
{
    $this->apply(Criterias\PatientObservation::isNull());
}

public function historyEqualsTo(string $clinicHistory): self
{
    $this->apply(Criterias\PatientClinicHistory::equals($clinicHistory));
}

public function documentNotEqualsTo(string $documentNumber): self
{
    $this->apply(Criterias\PatientIdentityDocument::notEquals($documentNumber));
}

public function inDocuments(array $documentNumbers): self
{
    $this->apply(Criterias\PatientIdentityDocument::in($documentNumbers));
}

protected function query(): Builder
{
    return Patient::query();
}
```

### indexed

[](#indexed)

Query by [`Index`](./tests/Utils/IndexRepository.php), evaluate the search strings and determine the index based on the given pattern.

```
public function indexes(): FilterBag
{
    return FilterBag::open()
        ->register(PatientIndex::Patient, $this->patientMustBe())
        ->register(PatientIndex::Name, $this->nameStartsWith())
        ->register(PatientIndex::Document, $this->documentIsEqualsTo());
}

protected function documentIsEqualsTo(): Closure
{
    return static fn(string $documentNumber) => PatientIdentityDocument::equals($documentNumber);
}

protected function nameStartsWith(): Closure
{
    return static fn(string $name) => PatientName::startsWith($name);
}

private function patientMustBe(): callable
{
    return static fn(string $queryString) => QueryStringMatcher::of(
        Query::must(
            target: 'document', mode: FilterOperator::Equal, expression: new NumericFixer(8)
        ),
    )->solve($queryString) ?: PatientName::startsWith($queryString);
}
```

### Filters

[](#filters)

Facility to apply dynamic [`Filters`](./tests/Utils/FlagFiltrator.php) through php enumerations.

```
public function flags(): FilterBag
{
    return FilterBag::open()
        ->register(PatientFlag::Observed, $this->onlyObserved())
        ->register(PatientFlag::WithAccount, $this->onlyWithAccount());
}

private function onlyObserved(): Closure
{
    return static fn() => PatientObservation::isNotNull();
}

private function onlyWithAccount(): Closure
{
    return static fn() => PatientScope::accounted();
}
```

More documentation
------------------

[](#more-documentation)

You can find a lot of comments within the source code as well as the tests located in the `tests` directory.

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance75

Regular maintenance activity

Popularity33

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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

Every ~80 days

Recently: every ~60 days

Total

13

Last Release

138d ago

Major Versions

v0.4 → v1.02024-08-30

v1.2.0 → v2.0.02025-05-05

PHP version history (2 changes)v0.1PHP ^8.1

v1.2.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ebfa2dc9bcd9f9f7cea1f5473811d3c3904f60716e5605ab0d7208a9a6b81f09?d=identicon)[vaened](/maintainers/vaened)

---

Top Contributors

[![vaened](https://avatars.githubusercontent.com/u/15077850?v=4)](https://github.com/vaened "vaened (36 commits)")

---

Tags

searchlaravelcriteriaeneavaened

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vaened-laravel-criteria/health.svg)

```
[![Health](https://phpackages.com/badges/vaened-laravel-criteria/health.svg)](https://phpackages.com/packages/vaened-laravel-criteria)
```

###  Alternatives

[romangrinev/laravel-opensearch-engine

Custom Laravel Scout OpenSearch Engine

1319.8k](/packages/romangrinev-laravel-opensearch-engine)[omure/scout-advanced-meilisearch

Laravel Scout extension that allows to use meilisearch advanced features as well as has an extended collection driver for testing purposes.

123.9k](/packages/omure-scout-advanced-meilisearch)

PHPackages © 2026

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