Skip to content

Commit

Permalink
Merge pull request #141 from ECFMP/139-avoiding-errors-over-now-times
Browse files Browse the repository at this point in the history
fix(FlowMeasureResource): force start time to now if needed
  • Loading branch information
AndyTWF authored Jul 10, 2022
2 parents c5fa7a3 + f4a8af1 commit 7c83075
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/Filament/Resources/FlowMeasureResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public static function form(Form $form): Form
->label(__('Start time [UTC]'))
->default(now()->addMinutes(5))
->withoutSeconds()
->minDate(fn (Page $livewire) => $livewire instanceof CreateRecord ? now() : now()->startOfDay())
->minDate(fn (Page $livewire) => $livewire instanceof CreateRecord ? now()->subMinutes(30) : now()->startOfDay())
->maxDate(now()->addDays(10))
->disabled(fn (Page $livewire, Closure $get) => !$livewire instanceof CreateRecord && !in_array($get('edit_mode'), [self::FULL_EDIT, self::PARTIAL_EDIT_WITH_START_TIME]))
->dehydrated(function (Page $livewire, Closure $get) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ protected function mutateFormDataBeforeCreate(array $data): array
$fir = FlightInformationRegion::find($data['flight_information_region_id']);

$startTime = Carbon::parse($data['start_time']);

if ($startTime->isBefore(now())) {
$startTime = now();
}

$data['identifier'] = FlowMeasureIdentifierGenerator::generateIdentifier($startTime, $fir);
$data['user_id'] = auth()->id();

Expand Down

0 comments on commit 7c83075

Please sign in to comment.