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 @@ + + 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 @@