JSend Response Macro's for Laravel
petarpetkovic996/laravel-jsend-response is a Laravel package for jsend response macro's for laravel.
It currently has 0 GitHub stars and 5 downloads on Packagist (latest version 1.0.0).
Install it with composer require petarpetkovic996/laravel-jsend-response.
Discover more Laravel packages by petarpetkovic996
or browse all Laravel packages to compare alternatives.
Last updated
This package defines JSend macros for the response in Laravel.
You can install the package via Composer:
composer require petarpetkovic996/laravel-jsend-response
$data = [
"first_name" => "Petar",
"last_name" => "Petkovic"
];
return response()->success($data, 201);
Result
{
"status": "success",
"data": {
"first_name": "Petar",
"last_name": "Petkovic"
}
}
With the HTTP Status Code: 201
$data = [
'first_name' => 'A first_name is required'
'last_name' => 'A last_name is required'
];
return response()->fail($data, 422);
Result
{
"status": "fail",
"data": {
"first_name": "A first_name is required"
"last_name": "A last_name is required"
}
}
With the HTTP Status Code: 422
return response()->error('Unable to communicate with database', 500);
Result
{
"status": "error",
"message": "Unable to communicate with database"
}
With the HTTP Status Code: 500