Romanovich095

Json response for laravel

Jul 15th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. /**
  2.      * Returns JSON Response that specified by project standards
  3.      *
  4.      * @param array $data
  5.      * @param array $errors
  6.      * @param null $message
  7.      * @param int $status
  8.      * @return \Illuminate\Http\JsonResponse
  9.      */
  10.     protected function jsonResponse($data = [], $errors = [], $message = null, $status = 200)
  11.     {
  12.         return response()
  13.             ->json([
  14.                 'data' => $data,
  15.                 'errors' => $errors,
  16.                 'message' => $message,
  17.                 'code' => $status
  18.             ], $status);
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment