noitran / rql by noitran

RQL - Resource Query Language package for laravel / lumen projects
13
0
1
Package Data
Maintainer Username: noitran
Maintainer Contact: noitran.black@gmail.com (Noitran.Black)
Package Create Date: 2019-02-25
Package Last Update: 2019-09-04
Language: PHP
License: MIT
Last Refreshed: 2024-12-15 15:09:58
Package Statistics
Total Downloads: 13
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 1
Total Forks: 0
Total Open Issues: 0

RQL - Resource Query Language Package

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.