From 5a848566f91641e93a3505fdab7bb36856c0512f Mon Sep 17 00:00:00 2001 From: snipe Date: Thu, 12 Jan 2017 02:19:17 -0800 Subject: [PATCH] Helper method to standardize JSON responses --- app/Helpers/Helper.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index a61c6bd20c..0a33bc4049 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -721,4 +721,16 @@ class Helper return ''; } } + + public static function formatStandardApiResponse($status, $payload = null, $messages = null) { + + $array['status'] = $status; + ($payload) ? $array['payload'] = $payload : ''; + + if (($messages) && (count($messages) > 0)) { + $array['messages'] = $messages; + } + + return $array; + } }