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; 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); } 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');