Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/amadeusdelfino/ventriloquist
Ventríloquo aims to provide a user-friendly and functional interface for complex database queries in the Laravel framework
https://github.com/amadeusdelfino/ventriloquist
eloquent json laravel php query relations select
Last synced: about 2 months ago
JSON representation
Ventríloquo aims to provide a user-friendly and functional interface for complex database queries in the Laravel framework
- Host: GitHub
- URL: https://github.com/amadeusdelfino/ventriloquist
- Owner: AmadeusDelfino
- License: mit
- Created: 2018-05-26T00:39:25.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-17T07:41:19.000Z (over 4 years ago)
- Last Synced: 2024-11-22T03:51:37.670Z (2 months ago)
- Topics: eloquent, json, laravel, php, query, relations, select
- Language: PHP
- Homepage:
- Size: 95.7 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ventriloquist
[![Build Status](https://travis-ci.org/AmadeusDelfino/ventriloquist.svg?branch=master)](https://travis-ci.org/AmadeusDelfino/ventriloquist)
[![StyleCI](https://github.styleci.io/repos/134916970/shield?branch=master)](https://github.styleci.io/repos/134916970)Suporte para fornecer uma interface única para consultas no banco de dados que utilizam ORMs com suporte a dotnotation
(como o Eloquent)## Exemplo de uso
```json
{
"values": [
{
"name": "name"
},
{
"name": "last_name"
},
{
"name": "salary"
},
{
"name": "email"
},
{
"name": "vacation",
"select": [
"id",
"start_date",
{
"name": "allowance",
"select": [
"id"
]
}
]
}
]
}
```
Como o Ventriloquist foi desenvolvido orientado a microserviços que utilizam mensageria (de forma reativa), eis um
exemplo de utilização em JSON, considerando que o padrão de mensagens utilizado seja JSON.Um array PHP que vai gerar um JSON dessa forma é o seguinte:
```php
array (
0 =>
array (
'name' => 'name',
),
1 =>
array (
'name' => 'last_name',
),
2 =>
array (
'name' => 'salary',
),
3 =>
array (
'name' => 'email',
),
4 =>
array (
'name' => 'vacation',
'select' =>
array (
0 => 'id',
1 => 'start_date',
2 =>
array (
'name' => 'allowance',
'select' =>
array (
0 => 'id',
),
),
),
)
```#### Implementação
```php
$parser = new Generator();
$parser->query($arrayQuery);
$parser->rootModel(new \My\Root\Model());
$parsed = $parser->parse();return $parsed->eloquentBuilder()->limit(10)->get();
```