bigpaulie / fractal-laravel-service
Fractal service provider for Laravel Framework
Installs: 121
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/bigpaulie/fractal-laravel-service
Requires
- php: >=5.6.4|^7
- illuminate/support: ^5.0
- league/fractal: dev-master
Requires (Dev)
- phpunit/phpunit: ~5.7
README
This is a simple service provider for Laravel 5.x
Installation
The preferred way to install the package is via composer
composer require bigpaulie/fractal-laravel-service
After installing the package you need to add the service provider to your config/app.php
bigpaulie\fractal\FractalServiceProvider::class
Usage
First you need to create your transformers afterwards you can use the response helper with the corresponding macro
Collections
return response()->collection($collection, new YourTransformer());
Collections with pagination
return response()->collection($collection, new YourTransformer(), $collection);
Items
return response()->item($item, new YourTransformer());
Exceptions
return response()->exception($exception, new YourTransformer());
Contribution
If you want to contribute to this project, please fork and submit a pull request.