| Package Data | |
|---|---|
| Maintainer Username: | leexikang |
| Maintainer Contact: | leexikang@gmail.com (Min San) |
| Package Create Date: | 2017-03-14 |
| Package Last Update: | 2017-03-17 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-02 03:01:10 |
| Package Statistics | |
|---|---|
| Total Downloads: | 41 |
| Monthly Downloads: | 0 |
| Daily Downloads: | 0 |
| Total Stars: | 0 |
| Total Watchers: | 1 |
| Total Forks: | 0 |
| Total Open Issues: | 0 |
For more about Fractal Please go to Fractal Document.
composer require min/fractalcommands
dd class to config/app.php
Min\FractalCommands\FractalCommandsServiceProvider::class
To use fractal on your controller, extend the Controller first which is created by the fractal:init command. Then call the tranform method povided by the Api Controller and pass the Sepcific tranformer class.
$this->transform(Post::all(), new PostTransformer);
To tranform single item (model), use tranform command
$this->transform(Post::find(1), new PostTransformer);
:warning: Call the parenet's (ApiController) constructor if you want to extend the Controller's constructor
parent::__construct();
The tranformer:create command will create the layout for your Tranformer in the App/Api/Tranformer Directory.
MIT