2017 © Pedro Peláez
 

library fractalcommands

Laravel commands for fractal

image

min/fractalcommands

Laravel commands for fractal

  • Friday, March 17, 2017
  • by leexikang
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Fractal-commands commands for using Fractal on Laravel's project.

For more about Fractal Please go to Fractal Document., (*1)

Install

composer require min/fractalcommands
add service provider

dd class to config/app.php, (*2)

Min\FractalCommands\FractalCommandsServiceProvider::class

Commands

  • php artisan fractal:init (create App/Api/Tranformer/ and Controllers/ApiControler)
  • php artisan tranformer:create {Tranformer} --model={model} (Create Tranformer in App\Api\Tranformer), (*3)

    Usages

    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., (*4)

    $this->transform(Post::all(), new PostTransformer); 
    

    To tranform single item (model), use tranform command, (*5)

    $this->transform(Post::find(1), new PostTransformer); 
    

    :warning: Call the parenet's (ApiController) constructor if you want to extend the Controller's constructor, (*6)

    parent::__construct(); 
    

    The tranformer:create command will create the layout for your Tranformer in the App/Api/Tranformer Directory., (*7)

Licence

MIT, (*8)

The Versions

17/03 2017

dev-master

9999999-dev

Laravel commands for fractal

  Sources   Download

MIT

by Min San

laravel commands fractal