From f037352a28fbd114781ff5a4e60bb168fa31925e Mon Sep 17 00:00:00 2001 From: edmondlang Date: Wed, 23 Feb 2022 18:13:57 +0800 Subject: [PATCH] cretae update document reference function --- .../UpdateDocumentReferenceLogic.php | 68 +++++++++++++++++++ .../Services/UpdatesDocumentReference.php | 20 ++++++ .../Rules/CanUpdateDocumentReference.php | 39 +++++++++++ .../UpdateDocumentReferenceController.php | 20 ++++++ .../IdentificationVerificationComponent.vue | 20 +++++- ...pdateIdentificationNumberFormComponent.vue | 49 +++++++++++++ routes/document.php | 2 + 7 files changed, 215 insertions(+), 3 deletions(-) create mode 100644 app/Classes/Modules/Documents/ControllersLogic/UpdateDocumentReferenceLogic.php create mode 100644 app/Classes/Modules/Documents/Services/UpdatesDocumentReference.php create mode 100644 app/Classes/Modules/Documents/Standards/Rules/CanUpdateDocumentReference.php create mode 100644 app/Http/Controllers/Documents/UpdateDocumentReferenceController.php create mode 100644 resources/assets/vue/components/companies/elements/UpdateIdentificationNumberFormComponent.vue diff --git a/app/Classes/Modules/Documents/ControllersLogic/UpdateDocumentReferenceLogic.php b/app/Classes/Modules/Documents/ControllersLogic/UpdateDocumentReferenceLogic.php new file mode 100644 index 00000000..e5d59101 --- /dev/null +++ b/app/Classes/Modules/Documents/ControllersLogic/UpdateDocumentReferenceLogic.php @@ -0,0 +1,68 @@ + 'Update Document Reference', + 'message' => 'You have successfully updated the Document Reference' + ]; + } + + /** @var CanUpdateDocumentReference*/ + private $canUpdateDocumentReference; + + /** @var UpdatesDocumentReference */ + private $updatesDocumentReference; + + /** @var FetchesDocument */ + private $fetchesDocument; + + + /** + * RejectDocumentLogic constructor. + * @param CanApproveDocument $canApproveDocument + * @param ApprovesDocument $approvesDocument + * @param FetchesDocument $fetchesDocument + */ + public function __construct(CanUpdateDocumentReference $canUpdateDocumentReference, UpdatesDocumentReference $updatesDocumentReference, FetchesDocument $fetchesDocument) + { + $this->canUpdateDocumentReference = $canUpdateDocumentReference; + $this->updatesDocumentReference = $updatesDocumentReference; + $this->fetchesDocument = $fetchesDocument; + } + + /** + * @param Request $request + * @return JsonResponse + * @throws \App\Classes\Exceptions\AccessForbiddenException + * @throws \App\Classes\Exceptions\MalformedRequestException + * @throws \App\Classes\Exceptions\RequestValidationException + */ + public function logic(Request $request) : JsonResponse + { + $document = $this->fetchesDocument->execute(['id' => $request->route('id')]); + + $this->canUpdateDocumentReference->passes(); + + $document_query = $this->updatesDocumentReference->execute($document, $request->input('identification_number')); + + return $this->resourceResponse(new DocumentResource($document_query)); + + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Documents/Services/UpdatesDocumentReference.php b/app/Classes/Modules/Documents/Services/UpdatesDocumentReference.php new file mode 100644 index 00000000..23a16e02 --- /dev/null +++ b/app/Classes/Modules/Documents/Services/UpdatesDocumentReference.php @@ -0,0 +1,20 @@ +reference = $reference; + return $this->handler($model); + } + +} \ No newline at end of file diff --git a/app/Classes/Modules/Documents/Standards/Rules/CanUpdateDocumentReference.php b/app/Classes/Modules/Documents/Standards/Rules/CanUpdateDocumentReference.php new file mode 100644 index 00000000..e6a29785 --- /dev/null +++ b/app/Classes/Modules/Documents/Standards/Rules/CanUpdateDocumentReference.php @@ -0,0 +1,39 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue b/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue index c5c26590..1c14a0fe 100644 --- a/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue +++ b/resources/assets/vue/components/companies/elements/IdentificationVerificationComponent.vue @@ -77,9 +77,21 @@
{{ item.owner.type === 0 ? 'IC' : 'SSM Registration' }} Number
-
+
-
{{item.reference}}
+
{{item.reference}}
+
+
+
+
+ +
+
+
+
+ +
+
@@ -182,7 +194,9 @@ export default { data() { return { - expanded: false + expanded: false, + isEditIdentificationNumber: false, + isEditCompanyName: false, } }, methods: { diff --git a/resources/assets/vue/components/companies/elements/UpdateIdentificationNumberFormComponent.vue b/resources/assets/vue/components/companies/elements/UpdateIdentificationNumberFormComponent.vue new file mode 100644 index 00000000..7fe3a240 --- /dev/null +++ b/resources/assets/vue/components/companies/elements/UpdateIdentificationNumberFormComponent.vue @@ -0,0 +1,49 @@ + + diff --git a/routes/document.php b/routes/document.php index 12419c9e..06f6badc 100644 --- a/routes/document.php +++ b/routes/document.php @@ -6,4 +6,6 @@ Route::group(['prefix' => 'document', 'as' => 'document.', 'namespace' => 'Docum Route::get('/list', 'ListDocumentsController@list')->name('list'); Route::put('/{id}/approve', 'ApproveDocumentController@approve')->name('status.approve'); Route::put('/{id}/reject', 'RejectDocumentController@reject')->name('status.reject'); + + Route::put('/{id}/reference/update', 'UpdateDocumentReferenceController@update')->name('reference.update'); }); \ No newline at end of file