PHPackages                             maartenpaauw/laravel-specification-pattern - 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. maartenpaauw/laravel-specification-pattern

ActiveLibrary

maartenpaauw/laravel-specification-pattern
==========================================

Filter an Illuminate collection with specifications

v3.1.0(1mo ago)1327.9k↓10.2%11MITPHPPHP ^8.2CI passing

Since Jan 21Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/maartenpaauw/laravel-specification-pattern)[ Packagist](https://packagist.org/packages/maartenpaauw/laravel-specification-pattern)[ Docs](https://github.com/maartenpaauw/laravel-specification-pattern)[ Fund](https://filamentphp.com/plugins/maartenpaauw-model-states)[ Fund](https://filamentphp.com/plugins/maartenpaauw-pennant)[ RSS](/packages/maartenpaauw-laravel-specification-pattern/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (36)Versions (16)Used By (1)

Laravel specification pattern
=============================

[](#laravel-specification-pattern)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8e4bba7b77f3c7d1fed75c3e3506fbae9e86eb39de7d59cc24635174e57b4b38/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61617274656e70616175772f6c61726176656c2d73706563696669636174696f6e2d7061747465726e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maartenpaauw/laravel-specification-pattern)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3fae41ec398e87e21ac5fd9b3c13b6de69efd6a59684bef9e4038777d9725afa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61617274656e70616175772f6c61726176656c2d73706563696669636174696f6e2d7061747465726e2f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/maartenpaauw/laravel-specification-pattern/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/997489db4009d1b13be657616d38ab53dd6249d3a702a7e2846c354681e9e0f5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d61617274656e70616175772f6c61726176656c2d73706563696669636174696f6e2d7061747465726e2f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/maartenpaauw/laravel-specification-pattern/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Codecov](https://camo.githubusercontent.com/b1a564cd6af6b86a0f7ff3205ebb64bdcda610b147db1a2055bc7d5a7dc754e3/68747470733a2f2f636f6465636f762e696f2f67682f6d61617274656e70616175772f6c61726176656c2d73706563696669636174696f6e2d7061747465726e2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d594d3941304455413452)](https://codecov.io/gh/maartenpaauw/laravel-specification-pattern)[![Total Downloads](https://camo.githubusercontent.com/648b9451ccd7562660aa387f15ed3a1261125a4bbdb6f541e46667bbea34c96e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61617274656e70616175772f6c61726176656c2d73706563696669636174696f6e2d7061747465726e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maartenpaauw/laravel-specification-pattern)

Filter an Illuminate collection with specifications.

Support me
----------

[](#support-me)

 [ ![Pennant for Filament](https://raw.githubusercontent.com/maartenpaauw/pennant-for-filament-docs/main/assets/screenshots/banner.jpg) ](https://filamentphp.com/plugins/maartenpaauw-pennant)

You can support me by [buying Pennant feature flags for Filament](https://filamentphp.com/plugins/maartenpaauw-pennant).

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

[](#installation)

You can install the package via composer:

```
composer require maartenpaauw/laravel-specification-pattern
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-specification-pattern-config"
```

This is the contents of the published config file:

```
return [
    'collection-method' => 'matching',
];
```

Usage
-----

[](#usage)

Here's how you can create a specification:

```
php artisan make:specification AdultSpecification
```

This will generate a specification class within the `App\Specifications` namespace.

```
