From 19b5a5762bd22af25ce64a367bf32176bb09d5c7 Mon Sep 17 00:00:00 2001 From: John Carter Date: Tue, 1 Oct 2024 13:55:00 +0100 Subject: [PATCH] Ensure hydrate date string is a Carbon instance --- src/Synthesizers/EntryCollectionSynthesizer.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Synthesizers/EntryCollectionSynthesizer.php b/src/Synthesizers/EntryCollectionSynthesizer.php index 49b5855..21610ab 100644 --- a/src/Synthesizers/EntryCollectionSynthesizer.php +++ b/src/Synthesizers/EntryCollectionSynthesizer.php @@ -5,6 +5,7 @@ use Livewire\Mechanisms\HandleComponents\Synthesizers\Synth; use Statamic\Entries\Entry; use Statamic\Entries\EntryCollection as StatamicEntryCollection; +use Illuminate\Support\Carbon; class EntryCollectionSynthesizer extends Synth { @@ -44,7 +45,13 @@ public function hydrate($values) ->data($value['data']); if ($value['date']) { - $entry->date($value['date'] ?? null); + $date = $value['date']; + + if (!$date instanceof \Carbon\CarbonInterface) { + $date = Carbon::parse($date); + } + + $entry->date($date ?? null); } $items[] = $entry;