PHPackages                             baethon/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. baethon/laravel-criteria

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

baethon/laravel-criteria
========================

Minimal interface for criteria pattern

1.1.0(3y ago)96.9k↑75%1[1 PRs](https://github.com/baethon/laravel-criteria/pulls)MITPHPPHP &gt;=8.1CI passing

Since Jun 28Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (3)Versions (6)Used By (0)

baethon/laravel-criteria
========================

[](#baethonlaravel-criteria)

Minimal implementation of [criteria pattern](https://www.tutorialspoint.com/design_pattern/filter_pattern.htm) for Laravel.

What is criteria?
-----------------

[](#what-is-criteria)

Criteria is an implementation of `\Baethon\LaravelCriteria\CriteriaInterface` which is responsible for only one thing - modify Laravels query in a specified way.

This allows to decouple and re-use query modifiers.

Criteria are very similar to [Eloquent scopes](https://laravel.com/docs/eloquent#query-scopes). The main difference is that they can be applied to different models across the application.

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

[](#installation)

```
composer require baethon/laravel-criteria
```

Requirements
------------

[](#requirements)

- PHP &gt;= 7.1

### Laravel compatibility

[](#laravel-compatibility)

This library has no dependencies to Laravel itself. It should work with all versions of Laravel.

Usage
-----

[](#usage)

First, you need to create an implementation of `CriteriaInterface`:

```
