From db2b86aa6d7c9dae9412c55711f375d1ad12abf0 Mon Sep 17 00:00:00 2001 From: Wouter Bles Date: Thu, 12 Oct 2023 22:19:20 +0200 Subject: [PATCH] Check null value in texts --- ...23_10_09_144100_set_english_text_default_agenda.php | 6 +++--- ...1123_set_english_text_default_agenda_categories.php | 2 +- ...23615_set_english_text_default_application_form.php | 2 +- ...5_set_english_text_default_application_form_row.php | 10 +--------- ...09_223615_set_english_text_default_certificates.php | 2 +- ...2023_10_09_223615_set_english_text_default_news.php | 4 ++-- ...2023_10_09_223615_set_english_text_default_page.php | 4 ++-- ...2023_10_09_223615_set_english_text_default_role.php | 2 +- 8 files changed, 12 insertions(+), 20 deletions(-) diff --git a/database/migrations/2023_10_09_144100_set_english_text_default_agenda.php b/database/migrations/2023_10_09_144100_set_english_text_default_agenda.php index f7c9ae20..9d26b2f2 100644 --- a/database/migrations/2023_10_09_144100_set_english_text_default_agenda.php +++ b/database/migrations/2023_10_09_144100_set_english_text_default_agenda.php @@ -28,9 +28,9 @@ public function up(): void $text = Text::find($item->text); $shortDescription = Text::find($item->shortDescription); - $item->title_string = $title->EN_text; - $item->text_string = $text->EN_text; - $item->shortDescription_string = $shortDescription->EN_text; + $item->title_string = $title ? $title->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->text_string = $text ? $text->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->shortDescription_string = $shortDescription ? $shortDescription->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); } diff --git a/database/migrations/2023_10_09_151123_set_english_text_default_agenda_categories.php b/database/migrations/2023_10_09_151123_set_english_text_default_agenda_categories.php index 226d84d4..82b21590 100644 --- a/database/migrations/2023_10_09_151123_set_english_text_default_agenda_categories.php +++ b/database/migrations/2023_10_09_151123_set_english_text_default_agenda_categories.php @@ -23,7 +23,7 @@ public function up(): void $agendaItemCategories = AgendaItemCategory::all(); foreach ($agendaItemCategories as $item) { $name = Text::find($item->name); - $item->name_string = $name->EN_text; + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); } diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_application_form.php b/database/migrations/2023_10_09_223615_set_english_text_default_application_form.php index f21a750f..5b8f6546 100644 --- a/database/migrations/2023_10_09_223615_set_english_text_default_application_form.php +++ b/database/migrations/2023_10_09_223615_set_english_text_default_application_form.php @@ -23,7 +23,7 @@ public function up(): void $items = ApplicationForm::all(); foreach ($items as $item) { $name = Text::find($item->name); - $item->name_string = $name->EN_text; + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); } diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row.php b/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row.php index fe1d1a6e..7c58f00f 100644 --- a/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row.php +++ b/database/migrations/2023_10_09_223615_set_english_text_default_application_form_row.php @@ -23,15 +23,7 @@ public function up(): void $items = ApplicationFormRow::all(); foreach ($items as $item) { $name = Text::find($item->name); - - if (!$name) { - echo "No text found for row id: " . $item->id . " and name " . $item->name . "\n"; - # Set name to error text - $name = new Text(); - $name->EN_text = "ERROR: Text not found"; - } - - $item->name_string = $name->EN_text; + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); } diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_certificates.php b/database/migrations/2023_10_09_223615_set_english_text_default_certificates.php index 56da9f0f..7f433968 100644 --- a/database/migrations/2023_10_09_223615_set_english_text_default_certificates.php +++ b/database/migrations/2023_10_09_223615_set_english_text_default_certificates.php @@ -23,7 +23,7 @@ public function up(): void $certificates = Certificate::all(); foreach ($certificates as $item) { $name = Text::find($item->name); - $item->name_string = $name->EN_text; + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); } diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_news.php b/database/migrations/2023_10_09_223615_set_english_text_default_news.php index 08a82014..f8b11c50 100644 --- a/database/migrations/2023_10_09_223615_set_english_text_default_news.php +++ b/database/migrations/2023_10_09_223615_set_english_text_default_news.php @@ -25,8 +25,8 @@ public function up(): void foreach ($news_items as $item) { $title = Text::find($item->title); $text = Text::find($item->text); - $item->title_string = $title->EN_text; - $item->text_string = $text->EN_text; + $item->title_string = $title ? $title->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->text_string = $text ? $text->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); } diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_page.php b/database/migrations/2023_10_09_223615_set_english_text_default_page.php index 3e503728..738ce7d8 100644 --- a/database/migrations/2023_10_09_223615_set_english_text_default_page.php +++ b/database/migrations/2023_10_09_223615_set_english_text_default_page.php @@ -25,8 +25,8 @@ public function up(): void foreach ($menu_items as $item) { $name = Text::find($item->name); $content = Text::find($item->content_id); - $item->name_string = $name->EN_text; - $item->content_string = $content->EN_text; + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; + $item->content_string = $content ? $content->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); } diff --git a/database/migrations/2023_10_09_223615_set_english_text_default_role.php b/database/migrations/2023_10_09_223615_set_english_text_default_role.php index d23d19fe..e16a8219 100644 --- a/database/migrations/2023_10_09_223615_set_english_text_default_role.php +++ b/database/migrations/2023_10_09_223615_set_english_text_default_role.php @@ -23,7 +23,7 @@ public function up(): void $roles = Rol::all(); foreach ($roles as $item) { $name = Text::find($item->name); - $item->name_string = $name->EN_text; + $item->name_string = $name ? $name->EN_text : 'ERROR: TEXT NOT FOUND'; $item->save(); }