From 8ee7bbe6b72c5ce9caafc3f70cc9559f3fa79052 Mon Sep 17 00:00:00 2001 From: Afzal Hossain Date: Fri, 20 Oct 2017 19:01:22 +0600 Subject: [PATCH 1/3] $app->get() no longer works. Replaced. --- templates/routes.wnt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/routes.wnt b/templates/routes.wnt index 5957ce1..edc27d5 100644 --- a/templates/routes.wnt +++ b/templates/routes.wnt @@ -1,8 +1,8 @@ /** * Routes for resource {{resource}} */ -$app->get('{{resource}}', '{{controller}}@all'); -$app->get('{{resource}}/{id}', '{{controller}}@get'); -$app->post('{{resource}}', '{{controller}}@add'); -$app->put('{{resource}}/{id}', '{{controller}}@put'); -$app->delete('{{resource}}/{id}', '{{controller}}@remove'); +$router->get('{{resource}}', '{{controller}}@all'); +$router->get('{{resource}}/{id}', '{{controller}}@get'); +$router->post('{{resource}}', '{{controller}}@add'); +$router->put('{{resource}}/{id}', '{{controller}}@put'); +$router->delete('{{resource}}/{id}', '{{controller}}@remove'); From ee03649641dfe469f14b04d9c2b38216d4ec74a6 Mon Sep 17 00:00:00 2001 From: Afzal Hossain Date: Fri, 20 Oct 2017 19:02:37 +0600 Subject: [PATCH 2/3] Single quote around model to avoid IDE warning --- templates/controller.wnt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/controller.wnt b/templates/controller.wnt index f02bc23..a25b548 100644 --- a/templates/controller.wnt +++ b/templates/controller.wnt @@ -2,7 +2,7 @@ class {{name}} extends Controller { - const MODEL = "{{model}}"; + const MODEL = '{{model}}'; use RESTActions; From 50c3e784835076d8f7f626044448451f2c0aedc9 Mon Sep 17 00:00:00 2001 From: Afzal Hossain Date: Fri, 20 Oct 2017 19:04:20 +0600 Subject: [PATCH 3/3] Better control over not_found and no_content response --- templates/controller/rest-actions.wnt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/controller/rest-actions.wnt b/templates/controller/rest-actions.wnt index 726910e..ac0f26f 100644 --- a/templates/controller/rest-actions.wnt +++ b/templates/controller/rest-actions.wnt @@ -53,6 +53,12 @@ trait RESTActions { protected function respond($status, $data = []) { + if($status == Response::HTTP_NO_CONTENT){ + return response(null,Response::HTTP_NO_CONTENT); + } + if($status == Response::HTTP_NOT_FOUND){ + return response(['message'=>'resource not found'],Response::HTTP_NOT_FOUND); + } return response()->json($data, $status); }