Skip to content

Special middleware to build WHERE condition array automatically from request for ORM package

License

Notifications You must be signed in to change notification settings

frameworkwtf/middleware-filters

Repository files navigation

Middleware Filters

Built for ORM package

Table of Contents

Installation

composer require wtf/middleware-filters

Add new middleware to your provider:

<?php

$container['middleware_filters'] = function ($c) {
    return new \Wtf\Middleware\Filters($c);
};

Add it to your suit.php middleware list:

<?php
//...
'middlewares' => [
//...
    'middleware_filters',
//...
],

Usage

Use medoo where conditions in your query, eg:

GET /?filter[name[~]]=Nich&limit=20&offset=20 => array:

<?php
[
    'name[~]' => 'Nich',
    'LIMIT' => [20,20],
];

And inside your code:

<?php

$collection = $this->entity('employee')->loadAll($this->container['filters']);

About

Special middleware to build WHERE condition array automatically from request for ORM package

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages