Download the PHP package nemesis/laravel-filter-and-sorting without Composer

On this page you can find all versions of the php package nemesis/laravel-filter-and-sorting. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-filter-and-sorting

Filter And Sorting Trait

Подключение

Подключите FilterAndSorting трейт к модели. Если вы хотите получать вложенные модели, нужно объявить метод extraFields(),

который будет возвращать список реляций, которые можно получить во вложениях. Как это использовать, будет описано ниже

Он подключается как scope к модели, что бы использовать, при запросе к модели нужно его вызвать:

Использование фильтра

Для фильтрации нужно использовать get параметр filter, в который помещается json с полями для фильтрации и параметрами.

Допустимые параметры:

isNull - не обязательный параметр, принимает true или false, добавляет к запросу AND $key IS NULL или AND $key IS NOT NULL

operation - логическая операция для выборки, принимает '>','<','>=','<=','<>','not in','in','like'

value - значение для выборки, может быть массивом, если используется "operation":"in" или "operation":"not in"

from и to - интервал. Могут работать по одиночке. Если приходят даты - они автоматически преобразуются в "компьютерный формат", так же можно передавать числа. Используются операторы >= и <=, т.е. значения from и to включаются в выборку.

Можно обращаться без параметров, а просто писать {"id":1}, тогда будет выполнен запрос WHERE id = 1 (AND подставится, если есть еще параметры выборки)

Примеры запросов:

/message?filter={"created_at":{"from":"2016-02-20","to":"2016-02-24 23:59:59"}, "id":{"operation":"not in", "value":[2,3,4]}}

/message?filter={"id":{"from":2,"to":5}}

/message?filter={"id":{"to":5}} и /message?filter={"id":{"operation":"<=","value":5}} - эквивалентны

/message?filter={"updated_at":{"isNull":true}}

/message?filter={"answer":{"operation":"like","value":"Partial search string"}} - псевдополнотекстовый поиск, добавляет услове вида: WHERE answer LIKE "%Partial search string%"

/message?filter={"answer":"Full search string"} - точный поиск по строке

Фильтр позволяет фильтровать по вложенным моделям:

/message?filter={"user.name":"asd"}

Вложенные модели должны быть разрешены в методе extraFields, фильтровать можно аналогично фильтру по текущей модели

Использование фильтра вложенных моделей

Для фильтрации нужно использовать get параметр filterExpand, работает аналогично обычному фильтру, только фильтрует данные во вложенных моделях

Использование сортировки

Сортировать можно по текущей модели, или по вложенной. Для сортировки необходимо передавать get параметр sort.

По умолчанию идет сортировка ASC, если нужно сделать DESC - перед полем для сортировки нужно ставить "-"/

Пример сортировки:

/message?sort=id

/message?sort=-id

/message?sort=user.name

Получение вложенных моделей

Для получения вложенных моделей (реляций), нужно разрешить их в методе модели extraFields() и при запросе добавлять get параметр expand.

Пример запроса:

/message?expand=user

Пример ответа:

{ "id": 1, "message": "some message", "user_id": 1, ... "user": { "id": 1, "name": "Some username", ... } }


All versions of laravel-filter-and-sorting with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nemesis/laravel-filter-and-sorting contains the following files

Loading the files please wait ....