Skip to content

Commit 81e6ec3

Browse files
committed
qc changes
1 parent f3b6f4a commit 81e6ec3

5 files changed

Lines changed: 95 additions & 35 deletions

File tree

app/CsrCampaignPage.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ public function resources()
3131

3232
public static function config(): self
3333
{
34-
$page = self::first();
35-
if ($page) {
36-
return $page;
37-
}
38-
39-
return self::create([
34+
$defaults = [
4035
'use_dynamic_content' => false,
4136
'hero_text' => __('csr-campaign.landing_header'),
4237
'primary_cta_text' => __('csr-campaign.get_involved'),
@@ -46,6 +41,23 @@ public static function config(): self
4641
'about_title' => __('csr-campaign.about_title'),
4742
'about_description' => __('csr-campaign.about_description'),
4843
'resources_title' => __('csr-campaign.resources'),
49-
]);
44+
];
45+
46+
$page = self::first();
47+
if ($page) {
48+
$dirty = false;
49+
foreach ($defaults as $key => $value) {
50+
if ($page->{$key} === null || $page->{$key} === '') {
51+
$page->{$key} = $value;
52+
$dirty = true;
53+
}
54+
}
55+
if ($dirty) {
56+
$page->save();
57+
}
58+
return $page;
59+
}
60+
61+
return self::create($defaults);
5062
}
5163
}

app/DancePage.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,31 @@ class DancePage extends Model
2424

2525
public static function config(): self
2626
{
27-
$page = self::first();
28-
if ($page) {
29-
return $page;
30-
}
31-
32-
return self::create([
27+
$defaults = [
3328
'use_dynamic_content' => false,
3429
'hero_title' => __('cw2020.title.0'),
3530
'hero_subtitle' => __('cw2020.dance.title'),
3631
'content_intro_title' => __('cw2020.dance.title'),
3732
'content_intro_subtitle' => __('snippets.dance.subtitle'),
3833
'get_involved_title' => __('cw2020.get-involved.title'),
3934
'get_involved_subtitle' => __('cw2020.get-involved.subtitle'),
40-
]);
35+
];
36+
37+
$page = self::first();
38+
if ($page) {
39+
$dirty = false;
40+
foreach ($defaults as $key => $value) {
41+
if ($page->{$key} === null || $page->{$key} === '') {
42+
$page->{$key} = $value;
43+
$dirty = true;
44+
}
45+
}
46+
if ($dirty) {
47+
$page->save();
48+
}
49+
return $page;
50+
}
51+
52+
return self::create($defaults);
4153
}
4254
}

app/GetInvolvedPage.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ class GetInvolvedPage extends Model
4747

4848
public static function config(): self
4949
{
50-
$page = self::first();
51-
if ($page) {
52-
return $page;
53-
}
54-
55-
return self::create([
50+
$defaults = [
5651
'use_dynamic_content' => false,
5752
'intro_heading' => 'How to get involved',
5853
'intro_text' => 'It’s easy to take part in Code Week. If you’re an educator, student, parent or community leader you can make a big impact. You can host your own activity, join one nearby, explore learning resources, or connect with others across Europe.',
@@ -71,6 +66,23 @@ public static function config(): self
7166
'card_ambassadors_text' => 'Ambassadors help coordinate Code Week in their countries. Reach out for support, advice or to join local projects and challenges.',
7267
'card_stories_title' => 'Share your coding experience and stories',
7368
'card_stories_text' => 'Post photos, videos and stories using #EUCodeWeek. Highlight what you’ve learned, celebrate your community, and inspire others to join',
74-
]);
69+
];
70+
71+
$page = self::first();
72+
if ($page) {
73+
$dirty = false;
74+
foreach ($defaults as $key => $value) {
75+
if ($page->{$key} === null || $page->{$key} === '') {
76+
$page->{$key} = $value;
77+
$dirty = true;
78+
}
79+
}
80+
if ($dirty) {
81+
$page->save();
82+
}
83+
return $page;
84+
}
85+
86+
return self::create($defaults);
7587
}
7688
}

app/OnlineCoursesPage.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ class OnlineCoursesPage extends Model
2626

2727
public static function config(): self
2828
{
29-
$page = self::first();
30-
if ($page) {
31-
return $page;
32-
}
33-
34-
return self::create([
29+
$defaults = [
3530
'use_dynamic_content' => false,
3631
'hero_title' => 'Online Courses',
3732
'hero_text' => __('online-courses.online-courses-text'),
@@ -41,6 +36,23 @@ public static function config(): self
4136
'intro_text_1' => __('online-courses.online-courses-sub-text1'),
4237
'intro_text_2' => __('online-courses.online-courses-sub-text2'),
4338
'intro_text_3' => __('online-courses.online-courses-sub-text3'),
44-
]);
39+
];
40+
41+
$page = self::first();
42+
if ($page) {
43+
$dirty = false;
44+
foreach ($defaults as $key => $value) {
45+
if ($page->{$key} === null || $page->{$key} === '') {
46+
$page->{$key} = $value;
47+
$dirty = true;
48+
}
49+
}
50+
if ($dirty) {
51+
$page->save();
52+
}
53+
return $page;
54+
}
55+
56+
return self::create($defaults);
4557
}
4658
}

app/TreasureHuntPage.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,7 @@ class TreasureHuntPage extends Model
3636

3737
public static function config(): self
3838
{
39-
$page = self::first();
40-
if ($page) {
41-
return $page;
42-
}
43-
44-
return self::create([
39+
$defaults = [
4540
'use_dynamic_content' => false,
4641
'hero_title' => 'Treasure Hunt',
4742
'hero_subtitle' => 'Simple yet challenging Telegram game – easy for beginners, engaging for experienced players.',
@@ -61,6 +56,23 @@ public static function config(): self
6156
'get_involved_link_3' => '/training',
6257
'get_involved_link_4' => 'https://bit.ly/DEEPDIVE2020',
6358
'get_involved_link_5' => '/resources/CodingAtHome',
64-
]);
59+
];
60+
61+
$page = self::first();
62+
if ($page) {
63+
$dirty = false;
64+
foreach ($defaults as $key => $value) {
65+
if ($page->{$key} === null || $page->{$key} === '') {
66+
$page->{$key} = $value;
67+
$dirty = true;
68+
}
69+
}
70+
if ($dirty) {
71+
$page->save();
72+
}
73+
return $page;
74+
}
75+
76+
return self::create($defaults);
6577
}
6678
}

0 commit comments

Comments
 (0)