Download the PHP package nastuzzi-samy/laravel-query-selection without Composer
On this page you can find all versions of the php package nastuzzi-samy/laravel-query-selection. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-query-selection
laravel-query-selector
A Laravel package that add some custom scopes on models to make a better selection via requests
Installation
With composer
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 => the developer defines as selectors as (s)he wants, but a selector is only usable if it is defined as key => each key is a selector: paginate, week, order... => 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 => if the default value isnull
or it is not defined if the array, this means that the selector is optional
Usage
In your targeted model:
In your targeted controller:
Let think we got 11 users, the 11th is the latest
Example 1: request /api/users?paginate=5
Output:
Example 2: request /api/users?paginate=3&order=random
Output:
Custom: You can also use your custom scopes !!
If you have installed the nastuzzi-samy\laravel-model-stages
for example
Usage example
In your targeted model:
In your targeted controller:
Let think we got a company tree with 1 Boss, 2 Supervisors and 4 Employees
Example 1: request /api/users?stage=0
Output:
Example 2: request /api/users?stage=0,1
Output:
Example 3: request /api/users?stage=2&order=random
Output:
All versions of laravel-query-selection with dependencies
illuminate/database Version >=5.0
nesbot/carbon Version >=1.0.0
symfony/http-kernel Version >=4.0.0
laravel/framework Version >=5.4