From 7e40f535cd7c30c3921a7d519c416a3774a6151c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Fri, 17 Nov 2023 13:45:03 +0100 Subject: [PATCH 1/3] fix: add nullable (#163) --- .../2023_10_25_171457_add_created_at_to_menu_table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..3556e367 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 @@ -12,7 +12,7 @@ public function up(): void { Schema::table('menu', function (Blueprint $table) { - $table->timestamp('created_at'); + $table->timestamp('created_at')->nullable(); }); } From b12e50265ddc23cf5bda4d1d0e651b9096bee36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Wed, 22 Nov 2023 14:32:25 +0100 Subject: [PATCH 2/3] feat: set null for searchitem (#166) * fix: fallback to null for SearchItem * style: formatting --- src/Services/Indexer/SearchItem.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) 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); + } } From 5e6a9b28cc2691d89abfb7bea058d709ce001450 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9?= Date: Wed, 22 Nov 2023 23:28:30 +0100 Subject: [PATCH 3/3] fix: only add column when it doesn't exist (#167) * fix: only add column when it doesn't exist * style: formatting --- .../2023_10_25_171457_add_created_at_to_menu_table.php | 3 +++ src/Services/Editor/FieldsProperties.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) 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 3556e367..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,6 +11,9 @@ */ public function up(): void { + if (Schema::hasColumn('menu', 'created_at')) { + return; + } Schema::table('menu', function (Blueprint $table) { $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); }