From d42712204c48285478df9ffbea74c65996e10f48 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 13 May 2014 22:48:02 +0300 Subject: [PATCH] Working on API --- app/config/app.php | 2 +- app/controllers/ClientApiController.php | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/config/app.php b/app/config/app.php index 9e09f8dfe9..6c1c3b5cb9 100755 --- a/app/config/app.php +++ b/app/config/app.php @@ -13,7 +13,7 @@ return array( | */ - 'debug' => true, + 'debug' => false, /* |-------------------------------------------------------------------------- diff --git a/app/controllers/ClientApiController.php b/app/controllers/ClientApiController.php index 3e6644232d..0686e52d19 100644 --- a/app/controllers/ClientApiController.php +++ b/app/controllers/ClientApiController.php @@ -16,12 +16,16 @@ class ClientApiController extends \BaseController { public function index() { - $clients = Client::scope()->get()->toArray(); + $clients = Client::scope()->get(); - return Response::json(array( - 'error' => false, - 'clients' => $clients), - 200 - ); + $response = [ + 'status' => 200, + 'error' => false, + 'clients' => $clients->toArray() + ]; + + $response = json_encode($response, JSON_PRETTY_PRINT); + + return Response::make($response, 200, ['Content-Type' => 'application/json']); } } \ No newline at end of file