all(); $result = $this->$MODEL_NAME_CAMEL$Repository->search($input); $$MODEL_NAME_PLURAL_CAMEL$ = $result[0]; return Response::json(ResponseManager::makeResult($$MODEL_NAME_PLURAL_CAMEL$->toArray(), "$MODEL_NAME_PLURAL$ retrieved successfully.")); } /** * Show the form for creating a new $MODEL_NAME$. * * @return Response */ public function create() { // } /** * Store a newly created $MODEL_NAME$ in storage. * * @param Request $request * * @return Response */ public function store(Request $request) { if(sizeof($MODEL_NAME$::$rules) > 0) $this->validateRequest($request, $MODEL_NAME$::$rules); $input = $request->all(); $$MODEL_NAME_CAMEL$ = $MODEL_NAME$::create($input); return Response::json(ResponseManager::makeResult($$MODEL_NAME_CAMEL$->toArray(), "$MODEL_NAME$ saved successfully.")); } /** * Display the specified $MODEL_NAME$. * * @param int $id * @param Request $request * * @return Response */ public function show($id) { /** @var $MODEL_NAME$ $$MODEL_NAME_CAMEL$ */ $$MODEL_NAME_CAMEL$ = $MODEL_NAME$::find($id); if(empty($$MODEL_NAME_CAMEL$)) $this->throwRecordNotFoundException("$MODEL_NAME$ not found", ERROR_CODE_RECORD_NOT_FOUND); return Response::json(ResponseManager::makeResult($$MODEL_NAME_CAMEL$->toArray(), "$MODEL_NAME$ retrieved successfully.")); } /** * Show the form for editing the specified $MODEL_NAME$. * * @param int $id * @return Response */ public function edit($id) { // } /** * Update the specified $MODEL_NAME$ in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { /** @var $MODEL_NAME$ $$MODEL_NAME_CAMEL$ */ $$MODEL_NAME_CAMEL$ = $MODEL_NAME$::find($id); if(empty($$MODEL_NAME_CAMEL$)) $this->throwRecordNotFoundException("$MODEL_NAME$ not found", ERROR_CODE_RECORD_NOT_FOUND); $input = $request->all(); $$MODEL_NAME_CAMEL$->fill($input); $$MODEL_NAME_CAMEL$->save(); return Response::json(ResponseManager::makeResult($$MODEL_NAME_CAMEL$->toArray(), "$MODEL_NAME$ updated successfully.")); } /** * Remove the specified $MODEL_NAME$ from storage. * * @param int $id * @return Response */ public function destroy($id) { /** @var $MODEL_NAME$ $$MODEL_NAME_CAMEL$ */ $$MODEL_NAME_CAMEL$ = $MODEL_NAME$::find($id); if(empty($$MODEL_NAME_CAMEL$)) $this->throwRecordNotFoundException("$MODEL_NAME$ not found", ERROR_CODE_RECORD_NOT_FOUND); $$MODEL_NAME_CAMEL$->delete(); return Response::json(ResponseManager::makeResult($id, "$MODEL_NAME$ deleted successfully.")); } }