This package allows you to send elegant json response from your Laravel api.
You can install the package via composer:
composer require avertys/json-api-response
return JsonApiResponse::make($data)
->withSuccess()
->send(200);
return JsonApiResponse::make($data)
->withSuccess()
->withAdditionalData([
'deprecated' => true
])
->send(200);
return JsonApiResponse::make()
->withErrors($validator->errors())
->withAdditionalData([
'deprecated' => true
])
->send(200);
return JsonApiResponse::make(User::paginate(10))
->withSuccess()
->send(200);
{
"success": true,
"data": [
"id": 1,
"name": "John"
],
"errors": null,
"additional_data": [
"pagination": {
"current_page": 2,
"to": 5,
"total": 100
},
"deprecated": false
]
}
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email hoostr.co@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.