Nullable dates in spatie/laravel-settings
Can anyone provide a basic example of how to define a settings class with a nullable date property?
I have this:
and a Page which provides a form with
From reading the docs, I can't tell what else would be required? The global cast for DateTimeInterface is set up per the docs and default config publication.
I have this:
and a Page which provides a form with
DateTimePicker::make('dateFrom')->seconds(false)->native(false); but every time I try to save where there is a date set, I am getting an error saying:Cannot assign string to property App\Settings\MySettings::$dateFrom of type ?DateTimeInterface
From reading the docs, I can't tell what else would be required? The global cast for DateTimeInterface is set up per the docs and default config publication.
Solution
I think that the problem is that you are saying the property has to be a Carbon/DateTime instance but your trying to set it as a string. Easyist thing to do would probably be to convert the string to a carbon instance.