mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-19 04:23:59 +00:00
update constant base price
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\Segments\ControllersLogic;
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\Segments\Services\FetchesConstant;
|
||||
use App\Classes\ValueObjects\Constants\SegmentConstants;
|
||||
use App\Http\Resources\ConstantResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\CarbonPeriod;
|
||||
|
||||
class FetchBasePriceLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved Base Price',
|
||||
'message' => 'You have successfully retrieved the Base Price'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/** @var FetchesConstant */
|
||||
private $fetchesConstant;
|
||||
|
||||
/**
|
||||
* FetchConstantLogic constructor.
|
||||
* @param FetchesConstant $fetchesConstant
|
||||
*/
|
||||
public function __construct(FetchesConstant $fetchesConstant)
|
||||
{
|
||||
$this->fetchesConstant = $fetchesConstant;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$constant = $this->fetchesConstant->execute(['segment_id' => $request->route('id'), 'reference' => SegmentConstants::BASE_PRICE]);
|
||||
|
||||
$constantObject = (array) $constant->value;
|
||||
|
||||
if ($request->input('dateFrom') !== null && $request->input('dateTo') !== null) {
|
||||
|
||||
$period = CarbonPeriod::create($request->input('dateFrom'), $request->input('dateTo'));
|
||||
|
||||
$returnObject = [];
|
||||
|
||||
foreach ($period as $date) {
|
||||
array_key_exists($date->format('Y-m-d'), $constantObject) === true ? $returnObject[$date->format('Y-m-d')] = $constantObject[$date->format('Y-m-d')] : '';
|
||||
}
|
||||
|
||||
$constant->value = json_encode($returnObject);
|
||||
|
||||
}
|
||||
|
||||
return $this->resourceResponse(new ConstantResource($constant));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Segments;
|
||||
|
||||
use App\Classes\Modules\Segments\ControllersLogic\FetchBasePriceLogic;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchBasePriceController
|
||||
{
|
||||
/**
|
||||
* @param Request $request
|
||||
* @param FetchSegmentLogic $logic
|
||||
* @return JsonResponse
|
||||
*/
|
||||
public function fetch(Request $request, FetchBasePriceLogic $logic): JsonResponse {
|
||||
return $logic->execute($request);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,15 +1,16 @@
|
||||
<template>
|
||||
<div class="row parentContainer" style="width: 450px; margin: auto;" @keyup.enter="submitForm">
|
||||
<div class="col bg-white b-rad-lg">
|
||||
<div class="row parentContainer padding-40 bg-white b-rad-lg" style="width: 450px; margin: auto;" @keyup.enter="submitForm">
|
||||
<div class="col">
|
||||
<div class="row m-b-10">
|
||||
<div class="col">
|
||||
<h2 class="text-center">Edit Base Price</h2>
|
||||
<p class="text-center">{{ parameters.dateFrom }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.value.amount">
|
||||
<validation-wrapper-component class="m-b-15" :validator="$v.parameters.rate">
|
||||
<label class="text-primary">Base Price (MYR)</label>
|
||||
<div class="controls">
|
||||
<input type="text" class="form-control fs-12" v-model.trim="parameters.value.amount" v-money="money">
|
||||
<input type="text" class="form-control fs-12" v-model.trim="parameters.rate" v-money="money">
|
||||
</div>
|
||||
</validation-wrapper-component>
|
||||
<div class="row m-t-15">
|
||||
@@ -17,7 +18,7 @@
|
||||
<div class="btn btn-lg btn-default b-rad-none" data-dismiss="modal">Cancel</div>
|
||||
</div>
|
||||
<div class="col p-l-5">
|
||||
<div class="btn btn-primary w-100 btn-lg" @click="submit(route('api.segment.constant.update', 1), 'put', section, true, true)">Confirm</div>
|
||||
<div class="btn btn-primary w-100 btn-lg" @click="submit(route('api.segment.constant.basePrice.create', 1), 'post', section, true, true)">Confirm</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -29,11 +30,10 @@
|
||||
|
||||
export default {
|
||||
props: {
|
||||
// pass in default base price
|
||||
// data: {
|
||||
// type: Object,
|
||||
// required: false
|
||||
// },
|
||||
data: {
|
||||
type: Object,
|
||||
required: false
|
||||
},
|
||||
section: {
|
||||
default: ''
|
||||
},
|
||||
@@ -41,18 +41,17 @@
|
||||
data() {
|
||||
return {
|
||||
parameters: {
|
||||
reference: 'BASE_PRICE',
|
||||
value : {
|
||||
amount: 0
|
||||
}
|
||||
}
|
||||
dateFrom: this.data.date,
|
||||
dateTo: this.data.date,
|
||||
rate: this.data.rate
|
||||
},
|
||||
};
|
||||
},
|
||||
validations: {
|
||||
parameters: {
|
||||
value: {
|
||||
amount: { required }
|
||||
}
|
||||
dateFrom: { required },
|
||||
dateTo: { required },
|
||||
rate: { required },
|
||||
}
|
||||
},
|
||||
mixins: [modalFormHandler]
|
||||
|
||||
@@ -254,18 +254,7 @@
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row m-b-20">
|
||||
<div class="col">
|
||||
<div class="row m-b-20 parentContainer" section="basePriceSection">
|
||||
<div class="col">
|
||||
<span class="font-heading all-caps fs-18 muted">Base Price </span> :0.00<i class="fa fa-edit pointer fa-fw m-l-5 requestModal text-primary" data-type="editBasePriceCharges"></i></div>
|
||||
<modal-component class="animate__animated animate__fast animate__fadeIn" type="editBasePriceCharges">
|
||||
{{-- <edit-base-price-form-component :data="{}" section="basePriceSection"></edit-base-price-form-component> --}}
|
||||
</modal-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<list-base-price-section-component section="basePriceSection"></list-base-price-section-component>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,5 +16,6 @@ Route::group(['prefix' => 'segment', 'as' => 'segment.', 'namespace' => 'Segment
|
||||
Route::put('/update/postcode', 'UpdateConstantPostcodeController@update')->name('update.postcode');
|
||||
|
||||
Route::post('base-price/create', 'CreateBasePriceController@create')->name('basePrice.create');
|
||||
Route::get('base-price/show', 'FetchBasePriceController@fetch')->name('basePrice.show');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user