diff --git a/app/Filament/Resources/FlowMeasureResource.php b/app/Filament/Resources/FlowMeasureResource.php index e609fbe5..be26354a 100644 --- a/app/Filament/Resources/FlowMeasureResource.php +++ b/app/Filament/Resources/FlowMeasureResource.php @@ -212,7 +212,7 @@ public static function form(Form $form): Form ->required() ->visible(fn (Closure $get) => $get('type') == FlowMeasureType::MANDATORY_ROUTE->value) ->schema([ - Forms\Components\Textarea::make('')->required() + Forms\Components\Textarea::make('mandatory_route')->required() ]), ]), self::filters($events), diff --git a/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php b/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php index 61c48216..f89c8b3c 100644 --- a/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php +++ b/app/Filament/Resources/FlowMeasureResource/Pages/CreateFlowMeasure.php @@ -123,6 +123,7 @@ protected function mutateFormDataBeforeCreate(array $data): array switch ($data['type']) { case FlowMeasureType::MANDATORY_ROUTE->value: Arr::pull($data, 'value'); + $data['mandatory_route'] = Arr::flatten($data['mandatory_route']); break; case FlowMeasureType::MINIMUM_DEPARTURE_INTERVAL->value: case FlowMeasureType::AVERAGE_DEPARTURE_INTERVAL->value: diff --git a/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php b/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php index bbf89b11..bac069fa 100644 --- a/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php +++ b/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php @@ -86,6 +86,14 @@ protected function mutateFormDataBeforeFill(array $data): array $data['filters'] = $newFilters->toArray(); + if (Arr::has($data, 'mandatory_route')) { + Arr::set($data, 'mandatory_route', collect($data['mandatory_route']) + ->map(function (string $value) { + return ['mandatory_route' => $value]; + }) + ->toArray()); + } + return $data; } @@ -96,6 +104,7 @@ protected function mutateFormDataBeforeSave(array $data): array switch ($data['type']) { case FlowMeasureType::MANDATORY_ROUTE->value: Arr::pull($data, 'value'); + $data['mandatory_route'] = Arr::flatten($data['mandatory_route']); break; case FlowMeasureType::MINIMUM_DEPARTURE_INTERVAL->value: case FlowMeasureType::AVERAGE_DEPARTURE_INTERVAL->value: diff --git a/app/Filament/Resources/FlowMeasureResource/Pages/ViewFlowMeasure.php b/app/Filament/Resources/FlowMeasureResource/Pages/ViewFlowMeasure.php index 650db681..c959ce4e 100644 --- a/app/Filament/Resources/FlowMeasureResource/Pages/ViewFlowMeasure.php +++ b/app/Filament/Resources/FlowMeasureResource/Pages/ViewFlowMeasure.php @@ -93,6 +93,14 @@ protected function mutateFormDataBeforeFill(array $data): array $data['filters'] = $newFilters->toArray(); + if (Arr::has($data, 'mandatory_route')) { + Arr::set($data, 'mandatory_route', collect($data['mandatory_route']) + ->map(function (string $value) { + return ['mandatory_route' => $value]; + }) + ->toArray()); + } + return $data; }