Skip to content

Commit

Permalink
Merge pull request #73 from johncarter-/fix/dated-collection-synthesizer
Browse files Browse the repository at this point in the history
Ensure date can be parsed by `Entry::make()`
  • Loading branch information
jonassiewertsen authored Oct 1, 2024
2 parents 676844e + 19b5a57 commit 7093f75
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 7093f75

Please sign in to comment.