GitHub - stephenlake/laravel-shovel: Light weight helpers and macros to assist i...
source link: https://github.com/stephenlake/laravel-shovel
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
A minimal package for shovelling data from an API to clients, for Laravel.
Laravel Shovel
Laravel Shovel is a minimalist package providing Laravel response macros to assist in rapid API development by transforming models, resources, collections, paginated objects and errors into a concise API response format. DRY.
Made with ❤️ by Stephen Lake
Getting Started
Install the package via composer.
composer require stephenlake/laravel-shovel
Transform Post::paginate();
into
{
"meta": {
"status": "success",
"message": "OK",
"code": 200,
"pagination": {
"records": 42312,
"page": 1,
"pages": 2821,
"limit": 15
}
},
"data": [{...},{...},{...}]
}
By using shovel(Post::paginate());
or shovel(Resource::collection(Post::paginate())
.
See documentation for usage.
License
This library is licensed under the MIT License - see the LICENSE.md file for details.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK