PHPackages                             nastuzzi-samy/laravel-query-selection - 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. [Database &amp; ORM](/categories/database)
4. /
5. nastuzzi-samy/laravel-query-selection

ActiveLibrary[Database &amp; ORM](/categories/database)

nastuzzi-samy/laravel-query-selection
=====================================

Add some custom scopes on models to make a better selection via requests

v2.5.0(6y ago)12.8k[3 issues](https://github.com/NastuzziSamy/laravel-query-selector/issues)[4 PRs](https://github.com/NastuzziSamy/laravel-query-selector/pulls)MITPHPPHP &gt;=7.1.3

Since Aug 1Pushed 3y ago2 watchersCompare

[ Source](https://github.com/NastuzziSamy/laravel-query-selector)[ Packagist](https://packagist.org/packages/nastuzzi-samy/laravel-query-selection)[ RSS](/packages/nastuzzi-samy-laravel-query-selection/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (8)Dependencies (4)Versions (30)Used By (0)

laravel-query-selector
======================

[](#laravel-query-selector)

A Laravel package that add some custom scopes on models to make a better selection via requests

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

[](#installation)

### With composer

[](#with-composer)

```
composer require NastuzziSamy/laravel-query-selector
```

Docs
----

[](#docs)

This trait add multiple scopes into model class They are all usable directly by calling them (withtout the "scope" behind) when querying for items

To work correctly, the developer must define this property:

- `selection` as a key/value array =&gt; the developer defines as selectors as (s)he wants, but a selector is only usable if it is defined as key =&gt; each key is a selector: paginate, week, order... =&gt; each value can be
    - a simple value (which is treated as like a default value)
    - an array with (if needed) a `default` key. Next, each selector as its column params =&gt; if the default value is `null` or it is not defined if the array, this means that the selector is optional

Usage
-----

[](#usage)

In your targeted model:

```
