fasberg/prettyresponse
Composer 安装命令:
composer require fasberg/prettyresponse
包简介
A helper for creating pretty api responses or just wrapping resources
README 文档
README
Installation
composer require fasberg/prettyresponse
Usage
use Fasberg\PrettyResponse\Facade\PrettyResponseFacade as PrettyResponse;
...
return PrettyResponse::wrap($resource, $options);
return PrettyResponse::conditional($condition, $resource, $options);
Wrap
Will take an array, collection or resource and wrap it in the base success response
Conditional
Conditional variable can be boolean, Closure or Collection.
It will default to trying to convert input into a boolean.
Data should be in the form of an array, collection or resource.
Options allows you to set a custom error/success message and return code
$options = [
'error' => [
'message' => 'My error message',
'code' => 123
],
'success' => [
'message' => 'My success message',
'code' => 321
]
];
Configuration
There is a configuration file available that will allow you to set global defaults.
Publish it by running
php artisan vendor:publish --provider="Fasberg\PrettyResponse\PrettyResponseServiceProvider"
统计信息
- 总下载量: 135
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-09-05