mosaiqo/optimus-prime

There is no license information available for the latest version (3.1.0) of this package.

A simple package to transform collection and entities to output to a JSON / API.

3.1.0 2015-07-03 13:08 UTC

README

Is a simple package to transform collection and entities TO a JSON - API before the response is returned to the requester. Think of it like the view presenter so you can adjust your output before, and maintain a clean API even if you change the DDBB structure.

Optimus Prime

Instalation

To install Mosaiqo Optimus Prime is really simple just install it with composer:

	composer require mosaiqo/optimus-prime "dev-master"

after it just put this line in your laravel app/config.php file :

	'Mosaiqo\OptimusPrime\TransformerServiceProvider',

now you can begin to play with your transformers.

How to transform your API

It's really easy to use Optimus Prime transformer.
In the model you want to use a transformer just have to implement the Mosaiqo\OptimusPrime\Decepticonsinterface. this interface forces you to use some methods to determine the transformer class.
But we have made it easy for you just pull in the Mosaiqo\OptimusPrime\Transformable trait we have created.


<?php namespace Foo\Bar;

use Illuminate\Database\Eloquent\Model;

use Mosaiqo\OptimusPrime\Contracts\Decepticons;
use Mosaiqo\OptimusPrime\Transformable;

class Foo extends Model implements Decepticons
{
	use Transformable;
	

}