Skip to content

Commit

Permalink
fix(FlowMeasureResource): force start time to now if needed
Browse files Browse the repository at this point in the history
Closes #139
  • Loading branch information
daveroverts committed Jul 10, 2022
1 parent 11740b0 commit f4a8af1
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 f4a8af1

Please sign in to comment.