Have expiry date depend on publish date value

I’ve two date pickers, a publish date and an expiry date. How can I link the two so the expiry date has to be within 28 days of the publish date? And if a publish day is set, then an earlier date selected, how do I ensure the expiry date is updated to be with the 28 day period? Here’s what I have but I get this error Call to a member function addDays() on string. If a date is already set there is no error but nothing updates live when values are changed.
Forms\Components\DateTimePicker::make('publish_date')
->live()
->prefixIcon('heroicon-o-calendar')
->minDate(now())
->seconds(false)
->minutesStep(5)
->native(false)
->disabled(fn(Vacancy $record) => $record->is_published),
Forms\Components\DatePicker::make('expiry_date')
->prefixIcon('heroicon-o-calendar')
->minDate(now())
// max date should always be 28 more than selected publish date
->maxDate(fn(Get $get) => $get('publish_date')->addDays(28))
->native(false)
Forms\Components\DateTimePicker::make('publish_date')
->live()
->prefixIcon('heroicon-o-calendar')
->minDate(now())
->seconds(false)
->minutesStep(5)
->native(false)
->disabled(fn(Vacancy $record) => $record->is_published),
Forms\Components\DatePicker::make('expiry_date')
->prefixIcon('heroicon-o-calendar')
->minDate(now())
// max date should always be 28 more than selected publish date
->maxDate(fn(Get $get) => $get('publish_date')->addDays(28))
->native(false)
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server