diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php index 71d0c542..1cf23d0c 100644 --- a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php +++ b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantLogic.php @@ -15,7 +15,7 @@ use App\Http\Resources\ConstantResource; use App\Models\SegmentConstant; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; -use App\Classes\Modules\Segments\Services\UpdatesConstantValueByState; +use App\Classes\Modules\Segments\Services\UpdatesConstantValue; class UpdateConstantLogic extends AbstractControllerLogic { @@ -48,8 +48,8 @@ class UpdateConstantLogic extends AbstractControllerLogic /** @var CreatesConstant */ private $createsConstant; - /** @var UpdatesConstantValueByState */ - private $updatesConstantValueByState; + /** @var UpdatesConstantValue */ + private $updatesConstantValue; /** * UpdateConstantLogic constructor. @@ -68,7 +68,7 @@ class UpdateConstantLogic extends AbstractControllerLogic FetchesConstant $fetchesConstant, CanCreateConstant $canCreateConstant, CreatesConstant $createsConstant, - UpdatesConstantValueByState $updatesConstantValueByState + UpdatesConstantValue $updatesConstantValue ) { $this->canUpdateConstant = $canUpdateConstant; @@ -77,7 +77,7 @@ class UpdateConstantLogic extends AbstractControllerLogic $this->fetchesConstant = $fetchesConstant; $this->canCreateConstant = $canCreateConstant; $this->createsConstant = $createsConstant; - $this->updatesConstantValueByState = $updatesConstantValueByState; + $this->updatesConstantValue = $updatesConstantValue; } /** * @param Request $request @@ -95,7 +95,7 @@ class UpdateConstantLogic extends AbstractControllerLogic $constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => $request->input('reference')]); - $constantValue = $this->updatesConstantValueByState->execute($constant->value, $request->input('id'), $request->input('rate')); + $constantValue = $this->updatesConstantValue->execute($constant->value, $request->input('id'), $request->input('rate')); $object = new ConstantObject($request->input('reference'), $constantValue); diff --git a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantStateLogic.php b/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantStateLogic.php deleted file mode 100644 index fe0b947b..00000000 --- a/app/Classes/Modules/Segments/ControllersLogic/UpdateConstantStateLogic.php +++ /dev/null @@ -1,118 +0,0 @@ - 'Updated Segment Constant', - 'message' => 'You have successfully updated the Segment Constant' - ]; - } - - /** @var CanUpdateConstant */ - private $canUpdateConstant; - - /** @var UpdatesConstant */ - private $updatesConstant; - - /** @var FetchesSegment */ - private $fetchesSegment; - - /** @var CreatesConstant */ - private $createsConstant; - - /** @var FetchesConstant */ - private $fetchesConstant; - - /** @var UpdatesConstantValueByState */ - private $updatesConstantValueByState; - - - /** - * UpdateConstantLogic constructor. - * @param CanUpdateConstant $canUpdateConstant - * @param UpdatesConstant $updatesConstant - * @param FetchesSegment $fetchesSegment - * @param FetchesConstant $fetchesConstant - * @param UpdatesConstantValueByState $updatesConstantValueByState - * @param CreatesConstant $createsConstant - */ - public function __construct( - CanUpdateConstant $canUpdateConstant, - UpdatesConstant $updatesConstant, - FetchesSegment $fetchesSegment, - FetchesConstant $fetchesConstant, - UpdatesConstantValueByState $updatesConstantValueByState, - CreatesConstant $createsConstant - ) - { - $this->canUpdateConstant = $canUpdateConstant; - $this->updatesConstant = $updatesConstant; - $this->fetchesSegment = $fetchesSegment; - $this->fetchesConstant = $fetchesConstant; - $this->updatesConstantValueByState = $updatesConstantValueByState; - $this->createsConstant = $createsConstant; - } - /** - * @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 - { - - $segment = $this->fetchesSegment->execute(['id' => $request->route('id')]); - - try { - - $constant = $this->fetchesConstant->execute(['segment_id' => $segment->id, 'reference' => SegmentConstants::STATE_RATE]); - - $constantValue = $this->updatesConstantValueByState->execute($constant->value, $request->input('id'), $request->input('rate')); - - $object = new ConstantObject(SegmentConstants::STATE_RATE, $constantValue); - - $this->canUpdateConstant->passes($object); - - } catch (ResourceNotFoundException $exception){ - - $constantObject = []; - - $constantObject[$request->input('id')] = $request->input('rate'); - - $object = new ConstantObject( - SegmentConstants::STATE_RATE, - $constantObject - ); - - $constant = $this->createsConstant->execute($segment, $object); - } - - $constant = $this->updatesConstant->execute($constant, $object); - - return $this->resourceResponse(new ConstantResource($constant)); - } - -} \ No newline at end of file diff --git a/app/Classes/Modules/Segments/Services/UpdatesConstantValueByState.php b/app/Classes/Modules/Segments/Services/UpdatesConstantValue.php similarity index 91% rename from app/Classes/Modules/Segments/Services/UpdatesConstantValueByState.php rename to app/Classes/Modules/Segments/Services/UpdatesConstantValue.php index fd283cb1..c8060940 100644 --- a/app/Classes/Modules/Segments/Services/UpdatesConstantValueByState.php +++ b/app/Classes/Modules/Segments/Services/UpdatesConstantValue.php @@ -2,7 +2,7 @@ namespace App\Classes\Modules\Segments\Services; -class UpdatesConstantValueByState +class UpdatesConstantValue { /** diff --git a/app/Http/Controllers/Segments/UpdateConstantStateController.php b/app/Http/Controllers/Segments/UpdateConstantStateController.php deleted file mode 100644 index 33e52100..00000000 --- a/app/Http/Controllers/Segments/UpdateConstantStateController.php +++ /dev/null @@ -1,20 +0,0 @@ -execute($request); - } - -} \ No newline at end of file diff --git a/resources/assets/vue/components/settings/forms/EditStateChargesFormComponent.vue b/resources/assets/vue/components/settings/forms/EditStateChargesFormComponent.vue index 6634a93d..f16c4981 100644 --- a/resources/assets/vue/components/settings/forms/EditStateChargesFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/EditStateChargesFormComponent.vue @@ -23,7 +23,7 @@
Cancel
-
Confirm
+
Confirm
@@ -48,6 +48,7 @@ cityCenterCharges: '', outskirtCharges : '', parameters: { + reference: 'STATE_RATE', id: this.data.id, rate: { center: this.data.stateCharges == null ? 0 : this.data.stateCharges.center, diff --git a/routes/segment.php b/routes/segment.php index d4406d71..af9c70c5 100644 --- a/routes/segment.php +++ b/routes/segment.php @@ -13,7 +13,6 @@ Route::group(['prefix' => 'segment', 'as' => 'segment.', 'namespace' => 'Segment Route::put('/service/update', 'UpdateCustomServiceConstantController@update')->name('service.update'); Route::put('/update', 'UpdateConstantController@update')->name('update'); Route::get('/show/{reference}', 'FetchConstantController@fetch')->name('show'); - Route::put('/update/state', 'UpdateConstantStateController@update')->name('update.state'); Route::put('/update/postcode', 'UpdateConstantPostcodeController@update')->name('update.postcode'); }); }); \ No newline at end of file