mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2024-12-26 14:05:29 +03:00
Merge pull request #48 from AfzalH/master
Some fixes for latest lumen. Also added customized response for NOT_FOUND and NO_CONTENT response
This commit is contained in:
commit
a6008f4a40
@ -2,7 +2,7 @@
|
||||
|
||||
class {{name}} extends Controller {
|
||||
|
||||
const MODEL = "{{model}}";
|
||||
const MODEL = '{{model}}';
|
||||
|
||||
use RESTActions;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user