diff --git a/plugins/ahmadfatoni/apigenerator/controllers/api/ContactUsController.php b/plugins/ahmadfatoni/apigenerator/controllers/api/ContactUsController.php new file mode 100644 index 0000000..941a44a --- /dev/null +++ b/plugins/ahmadfatoni/apigenerator/controllers/api/ContactUsController.php @@ -0,0 +1,105 @@ +ContactUs = $ContactUs; + $this->helpers = $helpers; + } + + public function index(){ + + $data = $this->ContactUs->all()->toArray(); + + $baseUrl = url('/storage/app/media'); + + foreach ($data as &$project) { + $project['image'] = $baseUrl . $project['image']; + } + + return $this->helpers->apiArrayResponseBuilder(200, 'success', $data); + } + + public function show($id){ + + $data = $this->ContactUs::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->ContactUs->{key($arr)} = $data; + next($arr); + } + + $validation = Validator::make($request->all(), $this->ContactUs->rules); + + if( $validation->passes() ){ + $this->ContactUs->save(); + return $this->helpers->apiArrayResponseBuilder(201, 'created', ['id' => $this->ContactUs->id]); + }else{ + return $this->helpers->apiArrayResponseBuilder(400, 'fail', $validation->errors() ); + } + + } + + public function update($id, Request $request){ + + $status = $this->ContactUs->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->ContactUs->where('id',$id)->delete(); + + return $this->helpers->apiArrayResponseBuilder(200, 'success', 'Data has been deleted successfully.'); + } + + public function destroy($id){ + + $this->ContactUs->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 e3accef..217fe15 100644 --- a/plugins/ahmadfatoni/apigenerator/routes.php +++ b/plugins/ahmadfatoni/apigenerator/routes.php @@ -17,4 +17,6 @@ Route::get('api/v1/cartoons/{id}/delete', ['as' => 'api/v1/cartoons.delete', 'us Route::resource('api/v1/mainServices', 'AhmadFatoni\ApiGenerator\Controllers\API\MainServicesController', ['except' => ['destroy', 'create', 'edit']]); Route::get('api/v1/mainServices/{id}/delete', ['as' => 'api/v1/mainServices.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\MainServicesController@destroy']); Route::resource('api/v1/contact', 'AhmadFatoni\ApiGenerator\Controllers\API\ContactController', ['except' => ['destroy', 'create', 'edit']]); -Route::get('api/v1/contact/{id}/delete', ['as' => 'api/v1/contact.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\ContactController@destroy']); \ No newline at end of file +Route::get('api/v1/contact/{id}/delete', ['as' => 'api/v1/contact.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\ContactController@destroy']); +Route::resource('api/v1/contactUs', 'AhmadFatoni\ApiGenerator\Controllers\API\ContactUsController', ['except' => ['destroy', 'create', 'edit']]); +Route::get('api/v1/contactUs/{id}/delete', ['as' => 'api/v1/contactUs.delete', 'uses' => 'AhmadFatoni\ApiGenerator\Controllers\API\ContactUsController@destroy']); \ No newline at end of file diff --git a/plugins/tps/tps/controllers/ContactUsController.php b/plugins/tps/tps/controllers/ContactUsController.php new file mode 100644 index 0000000..3ca928a --- /dev/null +++ b/plugins/tps/tps/controllers/ContactUsController.php @@ -0,0 +1,23 @@ + + + + + + diff --git a/plugins/tps/tps/controllers/contactuscontroller/config_form.yaml b/plugins/tps/tps/controllers/contactuscontroller/config_form.yaml new file mode 100644 index 0000000..d21fcf4 --- /dev/null +++ b/plugins/tps/tps/controllers/contactuscontroller/config_form.yaml @@ -0,0 +1,10 @@ +name: ContactUsController +form: $/tps/tps/models/contactus/fields.yaml +modelClass: Tps\Tps\Models\ContactUs +defaultRedirect: tps/tps/contactuscontroller +create: + redirect: 'tps/tps/contactuscontroller/update/:id' + redirectClose: tps/tps/contactuscontroller +update: + redirect: tps/tps/contactuscontroller + redirectClose: tps/tps/contactuscontroller diff --git a/plugins/tps/tps/controllers/contactuscontroller/config_list.yaml b/plugins/tps/tps/controllers/contactuscontroller/config_list.yaml new file mode 100644 index 0000000..bb778a4 --- /dev/null +++ b/plugins/tps/tps/controllers/contactuscontroller/config_list.yaml @@ -0,0 +1,12 @@ +list: $/tps/tps/models/contactus/columns.yaml +modelClass: Tps\Tps\Models\ContactUs +title: ContactUsController +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'tps/tps/contactuscontroller/update/:id' diff --git a/plugins/tps/tps/controllers/contactuscontroller/create.php b/plugins/tps/tps/controllers/contactuscontroller/create.php new file mode 100644 index 0000000..826cb96 --- /dev/null +++ b/plugins/tps/tps/controllers/contactuscontroller/create.php @@ -0,0 +1,46 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + +
+
+ + + + +

fatalError)) ?>

+

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

fatalError) ?>

+ + +

+ + + +

\ No newline at end of file diff --git a/plugins/tps/tps/controllers/contactuscontroller/update.php b/plugins/tps/tps/controllers/contactuscontroller/update.php new file mode 100644 index 0000000..3b736d5 --- /dev/null +++ b/plugins/tps/tps/controllers/contactuscontroller/update.php @@ -0,0 +1,54 @@ + + + + +fatalError): ?> + + 'layout']) ?> + +
+ formRender() ?> +
+ +
+
+ + + + + + + +
+
+ + + +

fatalError)) ?>

+

+ \ No newline at end of file diff --git a/plugins/tps/tps/models/ContactUs.php b/plugins/tps/tps/models/ContactUs.php new file mode 100644 index 0000000..33d79da --- /dev/null +++ b/plugins/tps/tps/models/ContactUs.php @@ -0,0 +1,24 @@ +increments('id')->unsigned(); + $table->string('title'); + $table->text('text'); + $table->string('image'); + $table->timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('tps_tps_contact_us'); + } +} diff --git a/plugins/tps/tps/updates/version.yaml b/plugins/tps/tps/updates/version.yaml index 9a20c56..4d30312 100644 --- a/plugins/tps/tps/updates/version.yaml +++ b/plugins/tps/tps/updates/version.yaml @@ -48,3 +48,6 @@ v1.0.16: v1.0.17: - 'Updated table tps_tps_cartoons' - builder_table_update_tps_tps_cartoons_3.php +v1.0.18: + - 'Created table tps_tps_contact_us' + - builder_table_create_tps_tps_contact_us.php