Skip to content

Commit

Permalink
Ensure hydrate date string is a Carbon instance
Browse files Browse the repository at this point in the history
  • Loading branch information
johncarter- committed Oct 1, 2024
1 parent 676844e commit 19b5a57
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Synthesizers/EntryCollectionSynthesizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 19b5a57

Please sign in to comment.