From e042836c60c83f8bd04b5bbf8c6a7ed1d35417aa Mon Sep 17 00:00:00 2001 From: gerchek Date: Fri, 21 Jan 2022 16:23:18 +0500 Subject: [PATCH] add api --- .../api/InformasiyaUslugahController.php | 99 +++++++++++++++++++ plugins/ahmadfatoni/apigenerator/routes.php | 4 +- .../SvedeniyaUslugahController.php | 19 ++++ .../_list_toolbar.htm | 19 ++++ .../_reorder_toolbar.htm | 3 + .../config_form.yaml | 10 ++ .../config_list.yaml | 12 +++ .../config_reorder.yaml | 4 + .../svedeniyauslugahcontroller/create.htm | 46 +++++++++ .../svedeniyauslugahcontroller/index.htm | 1 + .../svedeniyauslugahcontroller/preview.htm | 22 +++++ .../svedeniyauslugahcontroller/reorder.htm | 8 ++ .../svedeniyauslugahcontroller/update.htm | 54 ++++++++++ .../slider/models/InformasiyaObUslugah.php | 29 ++++++ .../models/informasiyaobuslugah/columns.yaml | 16 +++ .../models/informasiyaobuslugah/fields.yaml | 21 ++++ plugins/atash/slider/plugin.yaml | 4 + ...te_atash_slider_informasiya_ob_uslugah.php | 25 +++++ plugins/atash/slider/updates/version.yaml | 3 + 19 files changed, 398 insertions(+), 1 deletion(-) create mode 100644 plugins/ahmadfatoni/apigenerator/controllers/api/InformasiyaUslugahController.php create mode 100644 plugins/atash/slider/controllers/SvedeniyaUslugahController.php create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/_list_toolbar.htm create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/_reorder_toolbar.htm create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_form.yaml create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_list.yaml create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_reorder.yaml create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/create.htm create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/index.htm create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/preview.htm create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/reorder.htm create mode 100644 plugins/atash/slider/controllers/svedeniyauslugahcontroller/update.htm create mode 100644 plugins/atash/slider/models/InformasiyaObUslugah.php create mode 100644 plugins/atash/slider/models/informasiyaobuslugah/columns.yaml create mode 100644 plugins/atash/slider/models/informasiyaobuslugah/fields.yaml create mode 100644 plugins/atash/slider/updates/builder_table_create_atash_slider_informasiya_ob_uslugah.php diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/InformasiyaUslugahController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/InformasiyaUslugahController.php new file mode 100644 index 0000000..5b9bd8e --- /dev/null +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/InformasiyaUslugahController.php @@ -0,0 +1,99 @@ +InformasiyaObUslugah = $InformasiyaObUslugah; + $this->helpers = $helpers; + } + + public function index(){ + + $data = $this->InformasiyaObUslugah->all()->toArray(); + + return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); + } + + public function show($id){ + + $data = $this->InformasiyaObUslugah::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->InformasiyaObUslugah->{key($arr)} = $data; + next($arr); + } + + $validation = Validator::make($request->all(), $this->InformasiyaObUslugah->rules); + + if( $validation->passes() ){ + $this->InformasiyaObUslugah->save(); + return $this->helpers->apiArrayResponseBuilder(201, 'created', ['id' => $this->InformasiyaObUslugah->id]); + }else{ + return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validation->errors() ); + } + + } + + public function update($id, Request $request){ + + $status = $this->InformasiyaObUslugah->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->InformasiyaObUslugah->where('id',$id)->delete(); + + return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.'); + } + + public function destroy($id){ + + $this->InformasiyaObUslugah->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/routes.php b/plugins/ahmadfatoni/apigenerator/routes.php index 591b149..c9d08f3 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -15,4 +15,6 @@ Route::resource('api/v1/categories', 'AhmadFatoni\ApiGenerator\Controllers\API\c Route::get('api/v1/categories/{id}', ['as' => 'api/v1/categories.show', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\categoriesController@show']); Route::get('api/v1/categories/{id}/delete', ['as' => 'api/v1/categories.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\categoriesController@destroy']); Route::resource('api/v1/struktura_sentra', 'AhmadFatoni\ApiGenerator\Controllers\API\StrukturaSentraController', ['except' => ['destroy', 'create', 'edit']]); -Route::get('api/v1/struktura_sentra/{id}/delete', ['as' => 'api/v1/struktura_sentra.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\StrukturaSentraController@destroy']); \ No newline at end of file +Route::get('api/v1/struktura_sentra/{id}/delete', ['as' => 'api/v1/struktura_sentra.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\StrukturaSentraController@destroy']); +Route::resource('api/v1/insfor_usluh', 'AhmadFatoni\ApiGenerator\Controllers\API\InformasiyaUslugahController', ['except' => ['destroy', 'create', 'edit']]); +Route::get('api/v1/insfor_usluh/{id}/delete', ['as' => 'api/v1/insfor_usluh.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\InformasiyaUslugahController@destroy']); \ No newline at end of file diff --git a/plugins/atash/slider/controllers/SvedeniyaUslugahController.php b/plugins/atash/slider/controllers/SvedeniyaUslugahController.php new file mode 100644 index 0000000..218f006 --- /dev/null +++ b/plugins/atash/slider/controllers/SvedeniyaUslugahController.php @@ -0,0 +1,19 @@ + + + + + diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/_reorder_toolbar.htm b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/_reorder_toolbar.htm new file mode 100644 index 0000000..3c0d3a9 --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/_reorder_toolbar.htm @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_form.yaml b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_form.yaml new file mode 100644 index 0000000..5700c2b --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_form.yaml @@ -0,0 +1,10 @@ +name: SvedeniyaUslugahController +form: $/atash/slider/models/informasiyaobuslugah/fields.yaml +modelClass: Atash\Slider\Models\InformasiyaObUslugah +defaultRedirect: atash/slider/svedeniyauslugahcontroller +create: + redirect: 'atash/slider/svedeniyauslugahcontroller/update/:id' + redirectClose: atash/slider/svedeniyauslugahcontroller +update: + redirect: atash/slider/svedeniyauslugahcontroller + redirectClose: atash/slider/svedeniyauslugahcontroller diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_list.yaml b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_list.yaml new file mode 100644 index 0000000..68958b6 --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_list.yaml @@ -0,0 +1,12 @@ +list: $/atash/slider/models/informasiyaobuslugah/columns.yaml +modelClass: Atash\Slider\Models\InformasiyaObUslugah +title: SvedeniyaUslugahController +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'atash/slider/svedeniyauslugahcontroller/update/:id' diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_reorder.yaml b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_reorder.yaml new file mode 100644 index 0000000..bd464ea --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/config_reorder.yaml @@ -0,0 +1,4 @@ +title: SvedeniyaUslugahController +modelClass: Atash\Slider\Models\InformasiyaObUslugah +toolbar: + buttons: reorder_toolbar diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/create.htm b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/create.htm new file mode 100644 index 0000000..27a60f5 --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/create.htm @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/index.htm b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/index.htm @@ -0,0 +1 @@ +listRender() ?> diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/preview.htm b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/preview.htm new file mode 100644 index 0000000..ecf1225 --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/preview.htm @@ -0,0 +1,22 @@ + + + + +fatalError): ?> + +
+ formRenderPreview() ?> +
+ + +

fatalError) ?>

+ + +

+ + + +

\ No newline at end of file diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/reorder.htm b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/reorder.htm new file mode 100644 index 0000000..bdfc1c9 --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/reorder.htm @@ -0,0 +1,8 @@ + + + + +reorderRender() ?> \ No newline at end of file diff --git a/plugins/atash/slider/controllers/svedeniyauslugahcontroller/update.htm b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/update.htm new file mode 100644 index 0000000..a28ea47 --- /dev/null +++ b/plugins/atash/slider/controllers/svedeniyauslugahcontroller/update.htm @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + + +
+
+ + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/atash/slider/models/InformasiyaObUslugah.php b/plugins/atash/slider/models/InformasiyaObUslugah.php new file mode 100644 index 0000000..e381c0a --- /dev/null +++ b/plugins/atash/slider/models/InformasiyaObUslugah.php @@ -0,0 +1,29 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->string('kind_of_activity'); + $table->string('documents_for_employers'); + $table->string('order'); + $table->string('cost_of_work'); + }); + } + + public function down() + { + Schema::dropIfExists('atash_slider_informasiya_ob_uslugah'); + } +} diff --git a/plugins/atash/slider/updates/version.yaml b/plugins/atash/slider/updates/version.yaml index 5ec9304..07280bd 100644 --- a/plugins/atash/slider/updates/version.yaml +++ b/plugins/atash/slider/updates/version.yaml @@ -6,3 +6,6 @@ 1.0.3: - 'Created table atash_slider_struktura_sentra' - builder_table_create_atash_slider_struktura_sentra.php +1.0.4: + - 'Created table atash_slider_informasiya_ob_uslugah' + - builder_table_create_atash_slider_informasiya_ob_uslugah.php