diff --git a/app/Classes/Modules/Segments/ControllersLogic/FetchBasePriceLogic.php b/app/Classes/Modules/Segments/ControllersLogic/FetchBasePriceLogic.php new file mode 100644 index 00000000..49d24bd3 --- /dev/null +++ b/app/Classes/Modules/Segments/ControllersLogic/FetchBasePriceLogic.php @@ -0,0 +1,68 @@ + '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)); + } + +} \ No newline at end of file diff --git a/app/Http/Controllers/Segments/FetchBasePriceController.php b/app/Http/Controllers/Segments/FetchBasePriceController.php new file mode 100644 index 00000000..9ef0b225 --- /dev/null +++ b/app/Http/Controllers/Segments/FetchBasePriceController.php @@ -0,0 +1,20 @@ +execute($request); + } + +} \ No newline at end of file diff --git a/resources/assets/vue/components/settings/elements/ListBasePriceSectionComponent.vue b/resources/assets/vue/components/settings/elements/ListBasePriceSectionComponent.vue new file mode 100644 index 00000000..d2b12f67 --- /dev/null +++ b/resources/assets/vue/components/settings/elements/ListBasePriceSectionComponent.vue @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + Date From + + + + + + Date To + + + + + + + + + + + + Search + + + + + Reset + + + + + + + + + + + + + + + + + + + Date + + + + + {{ name }} + + + + + + + Rate + + + + + {{ value }} + + + + + + + Edit + + + + + + + + + + + + + + + + + Nothing To Show Here + + + + + There is no results found, Try adjusting your filters to find what you are looking for. + + + + + + + + + + + + + + + + + diff --git a/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue b/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue index 3fa9e870..742e95dc 100644 --- a/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue +++ b/resources/assets/vue/components/settings/forms/EditBasePriceFormComponent.vue @@ -1,15 +1,16 @@ - - + + Edit Base Price + {{ parameters.dateFrom }} - + Base Price (MYR) - + @@ -17,7 +18,7 @@ Cancel - Confirm + Confirm @@ -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] diff --git a/resources/views/pages/settings.blade.php b/resources/views/pages/settings.blade.php index 7463e2ec..615f3eb3 100644 --- a/resources/views/pages/settings.blade.php +++ b/resources/views/pages/settings.blade.php @@ -254,18 +254,7 @@ - - - - - Base Price :0.00 - - {{-- --}} - - - - - + diff --git a/routes/segment.php b/routes/segment.php index c74d7c06..1027db5e 100644 --- a/routes/segment.php +++ b/routes/segment.php @@ -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'); }); }); \ No newline at end of file
Nothing To Show Here
{{ parameters.dateFrom }}