Skip to content

Commit

Permalink
Check null value in texts
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterbles committed Oct 12, 2023
1 parent b92baa7 commit db2b86a
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit db2b86a

Please sign in to comment.