Package Data | |
---|---|
Maintainer Username: | kenmulford |
Maintainer Contact: | ken@kenmulford.com (Ken Mulford) |
Package Create Date: | 2015-04-07 |
Package Last Update: | 2015-04-10 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-14 15:10:16 |
Package Statistics | |
---|---|
Total Downloads: | 28 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
This extends the php artisan command list to include a command for generating a basic Fractal transformer based on your existing Eloquent model.
composer require 'mulford/generators' --dev
Open config/app.php
and add the line to the bottom of your providers
array:
"Mulford\Generators\TransformerGeneratorServiceProvider"
Run php artisan list
from the console and you will see make:transformer
in the "make" section.
By default, this library references models in the App\Models namespace (not the Laravel 5 default of App). It creates new Transformer classes in App\Transformers. In a future version I will try to make this a config option.
php artisan make:transformer --model=User
This command will create a basic Fractal Transformer class with some placeholders, as well as a basic transform() method. By default the transform() object array is populated based on the Eloquent model's $fillable
property. Obviously you can tweak the list as desired, but it serves as a decent starting point.
Eventually I hope to work out a way to create includes based on Eloquent relationships. If you are interested in helping feel free to send a pull request!