From c9885a8c9c75b6e282a1a001af68b95820a71371 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Tue, 18 Jun 2024 15:12:40 +0200 Subject: [PATCH] Add intro field for existing sections --- .../2024_06_18_170213_add_intro_field.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 database/migrations/2024_06_18_170213_add_intro_field.php diff --git a/database/migrations/2024_06_18_170213_add_intro_field.php b/database/migrations/2024_06_18_170213_add_intro_field.php new file mode 100644 index 00000000..025871be --- /dev/null +++ b/database/migrations/2024_06_18_170213_add_intro_field.php @@ -0,0 +1,47 @@ +get() as $event) { + $config = json_decode($event->config); + $config->sections = array_map(function ($section) { + if (!property_exists($section, 'intro')) { + $section->intro = null; + } + return $section; + }, $config->sections); + DB::table('forms')->where('id', $event->id)->update(['config' => json_encode($config)]); + } + + foreach (DB::table('formtemplates')->get() as $event) { + $config = json_decode($event->config); + $config->sections = array_map(function ($section) { + if (!property_exists($section, 'intro')) { + $section->intro = null; + } + return $section; + }, $config->sections); + DB::table('formtemplates')->where('id', $event->id)->update(['config' => json_encode($config)]); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +};