mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 12:34:01 +00:00
cretae update document reference function
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\ControllersLogic;
|
||||
|
||||
use App\Classes\Modules\Documents\Standards\Rules\CanUpdateDocumentReference;
|
||||
use App\Http\Resources\DocumentResource;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Documents\Services\FetchesDocument;
|
||||
use App\Classes\Modules\Documents\Services\UpdatesDocumentReference;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateDocumentReferenceLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => '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));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Services;
|
||||
|
||||
use App\Classes\General\Eloquent\AbstractUpdateRecord;
|
||||
use App\Models\Document;
|
||||
|
||||
class UpdatesDocumentReference extends AbstractUpdateRecord
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Document $model
|
||||
* @return mixed
|
||||
*/
|
||||
public function execute(Document $model, string $reference) {
|
||||
$model->reference = $reference;
|
||||
return $this->handler($model);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Documents\Standards\Rules;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractRule;
|
||||
use App\Classes\Modules\Documents\DataTransferObjects\DocumentObject;
|
||||
|
||||
class CanUpdateDocumentReference extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
protected function authorized(): bool
|
||||
{
|
||||
// TODO Set Authorization rules
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
protected function validators($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DocumentObject $object
|
||||
* @return bool
|
||||
*/
|
||||
protected function criteria($object): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Documents;
|
||||
|
||||
use App\Classes\Modules\Documents\ControllersLogic\UpdateDocumentReferenceLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class UpdateDocumentReferenceController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param UpdateDocumentReferenceLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function update(Request $request, UpdateDocumentReferenceLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
+17
-3
@@ -77,9 +77,21 @@
|
||||
<div class="fs-8 all-caps muted">{{ item.owner.type === 0 ? 'IC' : 'SSM Registration' }} Number</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="row" v-if="isEditIdentificationNumber === false">
|
||||
<div class="col">
|
||||
<div class="fs-11 text-primary bold">{{item.reference}}</div>
|
||||
<div class="fs-11 text-primary bold">{{item.reference}} <i class="fa fa-edit pointer fa-fw m-l-5" v-if="$store.getters.isSuperAdmin" @click="isEditIdentificationNumber = !isEditIdentificationNumber"></i></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row" v-if="isEditIdentificationNumber === true">
|
||||
<div class="col">
|
||||
<update-identification-number-form-component :section="section" :data="{identification_number: item.reference}" :id="item.id" v-on:submit="isEditIdentificationNumber=false"></update-identification-number-form-component>
|
||||
</div>
|
||||
<div class="col-auto d-flex align-items-center">
|
||||
<div class="row">
|
||||
<div class="col b-none btn btn-sm btn-danger" @click="isEditIdentificationNumber = !isEditIdentificationNumber">
|
||||
<i class="fa fa-times"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -182,7 +194,9 @@
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
expanded: false
|
||||
expanded: false,
|
||||
isEditIdentificationNumber: false,
|
||||
isEditCompanyName: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col p-r-0">
|
||||
<validation-wrapper-component :validator="$v.parameters.identification_number">
|
||||
<input type="text" class="form-control fs-12" placeholder="Edit identification number" v-model.trim="parameters.identification_number">
|
||||
</validation-wrapper-component>
|
||||
</div>
|
||||
<div class="col-auto bg-success d-flex justify-content-center align-items-center pointer text-white">
|
||||
<i class="fa fa-check" @click="submitForm"></i>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import modalFormHandler from '../../../general/mixins/modalFormHandler';
|
||||
import { required } from "vuelidate/lib/validators";
|
||||
|
||||
export default {
|
||||
props: {
|
||||
id: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
identification_number: this.identification_number,
|
||||
},
|
||||
};
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
identification_number: { required },
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.data) {
|
||||
this.parameters.identification_number = this.data.identification_number
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submitForm() {
|
||||
this.submit(this.route('api.document.reference.update', this.id), 'put', '', false, false);
|
||||
this.$emit('submit')
|
||||
}
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
}
|
||||
</script>
|
||||
@@ -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');
|
||||
});
|
||||
Reference in New Issue
Block a user