A simple way to define your Json Response for your Laravel's Api .
composer require kepsondiaz/httpjsonbridge
Send a response based on the event that occurs when your api is called
send a Response when a badRequest occur. Status code 400
/**
* Response with status code 400.
*/
return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->badRequestApiResponse([
'message' => 'your custom message for response'
]);
send a Response when response is OK.
/**
* Response with status code 200.
*/
return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->okApiResponse([
// do something
]);
send a Response when response when resource is not found
/**
* Response with status code 404.
*/
return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->notFoundApiResponse([
// do something
]);
send a Response when response when user is unauthorised
/**
* Response with status code 401.
*/
return (new \Kepsondiaz\HttpJsonBridge\HttpJsonBridge)->unauthorizedApiResponse([
// do something
]);