diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/contactController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/contactController.php deleted file mode 100644 index 196ae5a..0000000 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/contactController.php +++ /dev/null @@ -1,100 +0,0 @@ -Contacts = $Contacts; - $this->helpers = $helpers; - } - - public function index(){ - - $data = $this->Contacts->all()->toArray(); - - return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); - } - - public function show($id){ - - $data = $this->Contacts::find($id); - - if ($data){ - return $this->helpers->apiArrayResponseBuilder(200, 'success', [$data]); - } else { - $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']); - } - - } - - public function store(Request $request){ - - $arr = $request->all(); - unset($arr['/api/v1/contact']); - - while ( $data = current($arr)) { - $this->Contacts->{key($arr)} = $data; - next($arr); - } - - $validation = Validator::make($request->all(), $this->Contacts->rules); - - if( $validation->passes() ){ - $this->Contacts->save(); - return $this->helpers->apiArrayResponseBuilder(201, 'created', ['id' => $this->Contacts->id]); - }else{ - return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validation->errors() ); - } - - } - - public function update($id, Request $request){ - - $status = $this->Contacts->where('id',$id)->update($data); - - if( $status ){ - - return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been updated successfully.'); - - }else{ - - return $this->helpers->apiArrayResponseBuilder(400, 'bad request', 'Error, data failed to update.'); - - } - } - - public function delete($id){ - - $this->Contacts->where('id',$id)->delete(); - - return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.'); - } - - public function destroy($id){ - - $this->Contacts->where('id',$id)->delete(); - - return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.'); - } - - - public static function getAfterFilters() {return [];} - public static function getBeforeFilters() {return [];} - public static function getMiddleware() {return [];} - public function callAction($method, $parameters=false) { - return call_user_func_array(array($this, $method), $parameters); - } - -} \ No newline at end of file diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/mainServicesController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/mainServicesController.php deleted file mode 100644 index 32bac37..0000000 --- a/plugins/ahmadfatoni/apigenerator/controllers/api/mainServicesController.php +++ /dev/null @@ -1,99 +0,0 @@ -MainServices = $MainServices; - $this->helpers = $helpers; - } - - public function index(){ - - $data = $this->MainServices->all()->toArray(); - - return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); - } - - public function show($id){ - - $data = $this->MainServices::find($id); - - if ($data){ - return $this->helpers->apiArrayResponseBuilder(200, 'success', [$data]); - } else { - $this->helpers->apiArrayResponseBuilder(404, 'not found', ['error' => 'Resource id=' . $id . ' could not be found']); - } - - } - - public function store(Request $request){ - - $arr = $request->all(); - - while ( $data = current($arr)) { - $this->MainServices->{key($arr)} = $data; - next($arr); - } - - $validation = Validator::make($request->all(), $this->MainServices->rules); - - if( $validation->passes() ){ - $this->MainServices->save(); - return $this->helpers->apiArrayResponseBuilder(201, 'created', ['id' => $this->MainServices->id]); - }else{ - return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validation->errors() ); - } - - } - - public function update($id, Request $request){ - - $status = $this->MainServices->where('id',$id)->update($data); - - if( $status ){ - - return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been updated successfully.'); - - }else{ - - return $this->helpers->apiArrayResponseBuilder(400, 'bad request', 'Error, data failed to update.'); - - } - } - - public function delete($id){ - - $this->MainServices->where('id',$id)->delete(); - - return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.'); - } - - public function destroy($id){ - - $this->MainServices->where('id',$id)->delete(); - - return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.'); - } - - - public static function getAfterFilters() {return [];} - public static function getBeforeFilters() {return [];} - public static function getMiddleware() {return [];} - public function callAction($method, $parameters=false) { - return call_user_func_array(array($this, $method), $parameters); - } - -} \ No newline at end of file