noitran / rql
RQL - Resource Query Language package for laravel / lumen projects
0.2.0
2019-02-26 22:04 UTC
Requires
- php: >=7.2
- illuminate/database: ~5.7
- illuminate/support: ~5.7
Requires (Dev)
- nesbot/carbon: ^1.26.3
- orchestra/testbench: ~3.4.2|~3.5.0|~3.6.0|~3.7.0
- phpunit/phpunit: ~7.0
This package is auto-updated.
Last update: 2024-12-05 07:33:31 UTC
README
About
Package allows to use Resource Query Language (RQL) with Laravel's Eloquent ORM. Providers a simple and light-weight API for adding dynamic querying capabilities to HTTP based applications. Package functions as connector between HTTP requests and ORM. Currently only Eloquent Processor is included, but pacakge capabilities can be easly extended by adding new Processor.
Install
- Install as composer package
$ composer require noitran/rql
Usage
use Noitran\RQL\Tests\Stubs\Models\User; use Noitran\RQL\ExprQueue; use Noitran\RQL\Processors\EloquentProcessor; // Getting builder instance of model, or builder // instance from noitran/repositories also can be passed. $builder = User::query(); $queue = new ExprQueue(); // Creating expression $exprClasses = $this->queue->enqueue( new \Noitran\RQL\Expressions\EqExpr(null, 'name', 'John') ); // Attaching expression into builder $query = (new EloquentProcessor($this->builder))->process($exprClasses); // Thats it! Expression has been applied. Can be checked by dumping query. // Example: dd($query->toSql()); // Dumps attached expression to sql: // select * from "users" where "name" = ?
All samples can be viewed in testfile: Noitran\RQL\Tests\Processors\EloquentProcessorTest
Todo
- Add request / input parsers.
- Improve relation / column bindings.
- Improve docs and add more samples.