Package Data | |
---|---|
Maintainer Username: | Hesto |
Maintainer Contact: | biuro@deseco.pl (Andrzej Żmudziński) |
Package Create Date: | 2017-01-15 |
Package Last Update: | 2017-02-13 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:15:51 |
Package Statistics | |
---|---|
Total Downloads: | 1,605 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Laravel Wrapper for Fractal
composer require hesto/fractalfy
Add your new provider to the providers
array of config/app.php
:
'providers' => [
// ...
Hesto\Fractalfy\FractalfyServiceProvider::class,
// ...
],
Extend your controller with FractalfyController
class DashboardController extends FractalfyController
{
...
}
Return collection
$users = Users::all();
return $this->fractal
->collection($users, new UserTransformer)
->get();
Return resource with pagination
$users = Users::all();
return $this->fractal
->paginate($users, new UserTransformer)
->get();
Use Fractalfy Helpers (already included in FractalfyController)
Popular
return $this->respondOK();
return $this->respondNotFound();
return $this->respondUnauthorized();
return $this->respondUnprocessable();
return $this->respondBadRequest();
return $this->respondWithSuccess(200); //any success code
return $this->respondWithError(400); //any success code
Other
return $this->respondOK($message); //pass message to respond
return $this->setMessage($message)->respondOK();
return $this->setMessage($message)->setStatusCode($statuscode)->respondWithSuccess();
return $this->setMessage($message)->setStatusCode($statuscode)->respondWithError();