diff --git a/app/Filament/Resources/FlowMeasureResource.php b/app/Filament/Resources/FlowMeasureResource.php index 78378fdb..daa93b7a 100644 --- a/app/Filament/Resources/FlowMeasureResource.php +++ b/app/Filament/Resources/FlowMeasureResource.php @@ -217,7 +217,8 @@ public static function form(Form $form): Form self::filters($events), Forms\Components\Fieldset::make('FAO') ->schema([ - Forms\Components\BelongsToManyMultiSelect::make('notified_flight_information_regions') + Forms\Components\Select::make('notified_flight_information_regions') + ->multiple() ->columnSpan('full') ->required() ->helperText(__('The selected FIRs will receive a tag in discord and be visible in the API')) diff --git a/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php b/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php index bac069fa..53561c83 100644 --- a/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php +++ b/app/Filament/Resources/FlowMeasureResource/Pages/EditFlowMeasure.php @@ -152,6 +152,12 @@ protected function handleRecordUpdate(Model $record, array $data): Model $newFlowMeasure->identifier = FlowMeasureIdentifierGenerator::generateIdentifier($newFlowMeasure->start_time, $newFlowMeasure->flightInformationRegion); $newFlowMeasure->push(); + /* + * Because relationships are saved by the Select component for FAO and happen before this point, they + * end up being set for the previous model. Copy the FAO's across to the new model here. + */ + $newFlowMeasure->notifiedFlightInformationRegions()->sync($record->notifiedFlightInformationRegions->pluck('id')->toArray()); + $record->delete(); $this->record = $newFlowMeasure; diff --git a/app/Filament/Resources/FlowMeasureResource/Traits/Filters.php b/app/Filament/Resources/FlowMeasureResource/Traits/Filters.php index b17d4a84..865b3e56 100644 --- a/app/Filament/Resources/FlowMeasureResource/Traits/Filters.php +++ b/app/Filament/Resources/FlowMeasureResource/Traits/Filters.php @@ -137,10 +137,11 @@ public static function filters(Collection $events): Fieldset Block::make('member_event') ->icon('heroicon-o-calendar') ->schema([ - Forms\Components\Select::make('member_event') + Forms\Components\Select::make('value') ->label(__('Event')) ->hintIcon('heroicon-o-calendar') ->hintIcon('heroicon-o-calendar') + ->required() ->searchable() ->options( $events->mapWithKeys(fn (Event $event) => [$event->id => $event->name_date]) @@ -149,10 +150,11 @@ public static function filters(Collection $events): Fieldset Block::make('member_not_event') ->icon('heroicon-o-calendar') ->schema([ - Forms\Components\Select::make('member_not_event') + Forms\Components\Select::make('value') ->hintIcon('heroicon-o-calendar') ->label(__('Event')) ->hintIcon('heroicon-o-calendar') + ->required() ->searchable() ->options( $events->mapWithKeys(fn (Event $event) => [$event->id => $event->name_date])