From 2431c3828bbdc51bd09b7c18d58c2177983346f2 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 13 May 2014 23:24:40 +0300 Subject: [PATCH] Working on API --- app/controllers/ClientApiController.php | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/controllers/ClientApiController.php b/app/controllers/ClientApiController.php index 0686e52d1928..5f03a0ee90b8 100644 --- a/app/controllers/ClientApiController.php +++ b/app/controllers/ClientApiController.php @@ -18,14 +18,27 @@ class ClientApiController extends \BaseController { { $clients = Client::scope()->get(); + /* $response = [ 'status' => 200, 'error' => false, 'clients' => $clients->toArray() ]; + */ - $response = json_encode($response, JSON_PRETTY_PRINT); + $response = json_encode($clients->toArray(), JSON_PRETTY_PRINT); + $headers = [ + 'Content-Type' => 'application/json', + 'Access-Control-Allow-Origin' => '*', + 'Access-Control-Allow-Methods' => 'GET', + //'Access-Control-Allow-Headers' => 'Origin, Content-Type, Accept, Authorization, X-Requested-With', + //'Access-Control-Allow-Credentials' => 'true', + //'X-Total-Count' => 0 + //'X-Rate-Limit-Limit' - The number of allowed requests in the current period + //'X-Rate-Limit-Remaining' - The number of remaining requests in the current period + //'X-Rate-Limit-Reset' - The number of seconds left in the current period, + ]; - return Response::make($response, 200, ['Content-Type' => 'application/json']); + return Response::make($response, 200, $headers); } } \ No newline at end of file