Download the PHP package krasnikov/eloquent-json without Composer
On this page you can find all versions of the php package krasnikov/eloquent-json. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package eloquent-json
Laravel eloquent JSON API
Introduction
JSON:API is a specification for how a client should request that resources be fetched or modified, and how a server should respond to those requests.
JSON:API is designed to minimize both the number of requests and the amount of data transmitted between clients and servers. This efficiency is achieved without compromising readability, flexibility, or discoverability.
JSON:API requires use of the JSON:API media type (application/vnd.api+json) for exchanging data.
Install
composer require krasnikov/eloquent-json
- add
\Krasnikov\EloquentJSON\EloquentJsonServiceProvider::class,
to Application Service Providers php artisan vendor:publish --provider="Krasnikov\EloquentJSON\EloquentJsonServiceProvider" --tag=config
php artisan vendor:publish --provider="Krasnikov\EloquentJSON\EloquentJsonServiceProvider" --tag=translations
- change date format and route prefix in
config/jsonSpec.php
, - if you need object id in attributes set
'show_id' => true
inconfig/jsonSpec.php
, - use
ModelJson
trait in your models
or extended it JsonModel
class
-
use parameter
$allowedReferences
in your model for define allowed reference list - use in your controller for set pagination and send object to repository;
- use in your controller for set sorting and send object to repository.
In repository use method
setBuilder
for set sorting to query builder$sorting->setBuilder($builder)
; - use Model method
toJsonSpec()
in your controller for get response structure
Load relationships
Sparse Fieldsets
Pagination
Response example
Sample output
CHANGELOG.md