Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit 1213d4f

Browse files
author
Andrey Helldar
committed
Added the ability to transfer additional content
1 parent 49e9cef commit 1213d4f

File tree

6 files changed

+187
-123
lines changed

6 files changed

+187
-123
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Instead, you may of course manually update your require block and run `composer
2626
```json
2727
{
2828
"require": {
29-
"andrey-helldar/api-response": "^4.0"
29+
"andrey-helldar/api-response": "^4.3"
3030
}
3131
}
3232
```
@@ -158,6 +158,30 @@ returned with code 200:
158158

159159
If the first parameter is a number, then the decryption of the error by code will be returned. In other cases, the value of the passed variable will be returned.
160160

161+
162+
## with additional content
163+
```php
164+
return api_response('title', 200, [], ['foo' => 'bar']);
165+
```
166+
returned with code 200:
167+
```json
168+
{
169+
"content": "title",
170+
"foo": "bar"
171+
}
172+
```
173+
174+
returned with code 400:
175+
```json
176+
{
177+
"error": {
178+
"code": 400,
179+
"msg":"ok"
180+
},
181+
"foo": "bar"
182+
}
183+
```
184+
161185
### Using in Laravel 5+ framework
162186

163187
To use you need to add three methods to the file `app/Exceptions/Handler.php`:

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
],
1717
"require": {
1818
"php": ">=5.6.9",
19+
"ext-json": "*",
1920
"symfony/http-foundation": "^3.0|^4.0"
2021
},
2122
"require-dev": {

0 commit comments

Comments
 (0)