diff --git a/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php b/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php index c5c9f83b..c7fc39fe 100644 --- a/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php +++ b/database/migrations/2023_10_25_171457_add_created_at_to_menu_table.php @@ -11,8 +11,11 @@ */ public function up(): void { + if (Schema::hasColumn('menu', 'created_at')) { + return; + } Schema::table('menu', function (Blueprint $table) { - $table->timestamp('created_at'); + $table->timestamp('created_at')->nullable(); }); } diff --git a/src/Services/Editor/FieldsProperties.php b/src/Services/Editor/FieldsProperties.php index 806dfc4e..b2967609 100644 --- a/src/Services/Editor/FieldsProperties.php +++ b/src/Services/Editor/FieldsProperties.php @@ -150,7 +150,7 @@ private function addLayoutFields(array $properties, LayoutForm &$form) // $checkboxField->setValue(true); // } else { $checkboxField->setValue(false); - // } + // } } else { $checkboxField->setValue($value ?? false); } diff --git a/src/Services/Indexer/SearchItem.php b/src/Services/Indexer/SearchItem.php index 38b70e2d..52cd12ca 100644 --- a/src/Services/Indexer/SearchItem.php +++ b/src/Services/Indexer/SearchItem.php @@ -17,9 +17,9 @@ final class SearchItem private bool $inSitemap = true; - private ?DateTime $publicationDate; + private ?DateTime $publicationDate = null; - private ?DateTime $lastUpdated; + private ?DateTime $lastUpdated = null; private int $priority = 1; @@ -146,12 +146,7 @@ public function content(): ?string */ public function publicationDate(): ?string { - $time = $this->publicationDate ?? $this->lastUpdated; - if ($time === null) { - return null; - } - - return $time->format(DateTime::ATOM); + return $this->toDateString($this->publicationDate ?? $this->lastUpdated); } /** @@ -162,12 +157,7 @@ public function publicationDate(): ?string */ public function lastUpdated(): ?string { - $time = $this->lastUpdated ?? $this->publicationDate; - if ($time === null) { - return null; - } - - return $time->format(DateTime::ATOM); + return $this->toDateString($this->lastUpdated ?? $this->publicationDate); } public function customValues(): ?array @@ -189,4 +179,13 @@ public function sitemap(): bool { return $this->inSitemap; } + + private function toDateString(?DateTime $date): ?string + { + if ($date === null) { + return null; + } + + return $date->format(DateTime::ATOM); + } }