Skip to content

Commit 3db8a27

Browse files
authored
Merge pull request #3511 from codeeu/feature/support-gmail-oauth
qc changes
2 parents 99a2f46 + f2c806e commit 3db8a27

6 files changed

Lines changed: 300 additions & 117 deletions

File tree

app/GetInvolvedPage.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace App;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
7+
class GetInvolvedPage extends Model
8+
{
9+
protected $table = 'get_involved_page';
10+
11+
protected $fillable = [
12+
'use_dynamic_content',
13+
'intro_heading',
14+
'intro_text',
15+
'intro_button_text',
16+
'intro_button_link',
17+
'movement_heading',
18+
'movement_text_1',
19+
'movement_text_2',
20+
'start_heading',
21+
'start_text',
22+
'card_community_title',
23+
'card_community_text',
24+
'card_community_link',
25+
'card_community_new_tab',
26+
'card_activity_title',
27+
'card_activity_text',
28+
'card_activity_link',
29+
'card_activity_new_tab',
30+
'card_ambassadors_title',
31+
'card_ambassadors_text',
32+
'card_ambassadors_link',
33+
'card_ambassadors_new_tab',
34+
'card_stories_title',
35+
'card_stories_text',
36+
'card_stories_link',
37+
'card_stories_new_tab',
38+
];
39+
40+
protected $casts = [
41+
'use_dynamic_content' => 'boolean',
42+
'card_community_new_tab' => 'boolean',
43+
'card_activity_new_tab' => 'boolean',
44+
'card_ambassadors_new_tab' => 'boolean',
45+
'card_stories_new_tab' => 'boolean',
46+
];
47+
48+
public static function config(): self
49+
{
50+
$page = self::first();
51+
if ($page) {
52+
return $page;
53+
}
54+
55+
return self::create([
56+
'use_dynamic_content' => false,
57+
'intro_button_link' => '/guide',
58+
]);
59+
}
60+
}

app/Nova/GetInvolvedPage.php

Lines changed: 61 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@
55
use Illuminate\Http\Request;
66
use Laravel\Nova\Fields\Boolean;
77
use Laravel\Nova\Fields\ID;
8-
use Laravel\Nova\Fields\Select;
98
use Laravel\Nova\Fields\Text;
10-
use Laravel\Nova\Fields\Textarea;
9+
use Laravel\Nova\Fields\Trix;
1110
use Laravel\Nova\Http\Requests\NovaRequest;
11+
use Laravel\Nova\Panel;
1212

1313
class GetInvolvedPage extends Resource
1414
{
1515
public static $group = 'Content';
1616

17-
public static $model = \App\StaticPage::class;
17+
public static $model = \App\GetInvolvedPage::class;
1818

19-
public static $title = 'name';
19+
public static $title = 'id';
2020

2121
public static $priority = 10;
2222

@@ -42,90 +42,73 @@ public static function authorizedToViewAny(Request $request): bool
4242

4343
public static function indexQuery(NovaRequest $request, $query)
4444
{
45-
return $query->where('path', '/get-involved')->orWhere('unique_identifier', 'get-involved');
45+
return $query->where('id', 1);
4646
}
4747

4848
public static function relatableQuery(NovaRequest $request, $query)
4949
{
50-
return $query->where('path', '/get-involved')->orWhere('unique_identifier', 'get-involved');
51-
}
52-
53-
public function fields(Request $request): array
54-
{
55-
return [
56-
ID::make()->sortable(),
57-
58-
Text::make('Name')
59-
->sortable()
60-
->rules('required', 'max:255'),
61-
62-
Boolean::make('Is Searchable', 'is_searchable'),
63-
64-
Select::make('Category')
65-
->options([
66-
'General' => 'General',
67-
'Challenges' => 'Challenges',
68-
'Tranning' => 'Tranning',
69-
'Online Courses' => 'Online Courses',
70-
'Other' => 'Other',
71-
])
72-
->nullable()
73-
->displayUsingLabels(),
74-
75-
Select::make('Link Type', 'link_type')
76-
->options([
77-
'internal_link' => 'Internal Link',
78-
'external_link' => 'External Link',
79-
])
80-
->rules('required')
81-
->displayUsingLabels(),
82-
83-
Textarea::make('Description')->nullable(),
84-
85-
Text::make('Language')
86-
->sortable()
87-
->rules('required', 'size:2')
88-
->default('en'),
89-
90-
Text::make('Unique Identifier')
91-
->rules('required', 'unique:static_pages,unique_identifier,{{resourceId}}'),
92-
93-
Text::make('Path')
94-
->readonly()
95-
->rules('required', 'unique:static_pages,path,{{resourceId}}'),
96-
97-
Text::make('Keywords')
98-
->rules('nullable')
99-
->help('Enter keywords separated by commas, e.g., coding, education, technology.'),
100-
101-
Text::make('Thumbnail')->nullable(),
102-
103-
Text::make('Meta Title')->nullable(),
104-
105-
Textarea::make('Meta Description')->nullable(),
106-
107-
Textarea::make('Meta Keywords')->nullable(),
108-
];
50+
return $query->where('id', 1);
10951
}
11052

11153
public static function authorizedToCreate(Request $request): bool
11254
{
113-
return true;
55+
return false;
11456
}
11557

116-
public static function redirectAfterCreate(NovaRequest $request, $resource)
117-
{
118-
return '/resources/' . static::uriKey() . '/' . $resource->id;
119-
}
120-
121-
public static function fill(NovaRequest $request, $model)
58+
public function fields(Request $request): array
12259
{
123-
$model->path = $model->path ?: '/get-involved';
124-
$model->unique_identifier = $model->unique_identifier ?: 'get-involved';
125-
$model->language = $model->language ?: 'en';
126-
$model->link_type = $model->link_type ?: 'internal_link';
127-
$model->name = $model->name ?: 'Get Involved';
128-
129-
return parent::fill($request, $model);
60+
return [
61+
ID::make()->onlyOnForms(),
62+
63+
Panel::make('General', [
64+
Boolean::make('Use dynamic content for this page', 'use_dynamic_content'),
65+
])->collapsable()->collapsedByDefault(),
66+
67+
Panel::make('Hero', [
68+
Text::make('Heading', 'intro_heading')->nullable(),
69+
Trix::make('Intro text', 'intro_text')->nullable(),
70+
Text::make('Button text', 'intro_button_text')->nullable(),
71+
Text::make('Button link', 'intro_button_link')->nullable(),
72+
])->collapsable()->collapsedByDefault(),
73+
74+
Panel::make('Movement section', [
75+
Text::make('Heading', 'movement_heading')->nullable(),
76+
Trix::make('Paragraph 1', 'movement_text_1')->nullable(),
77+
Trix::make('Paragraph 2', 'movement_text_2')->nullable(),
78+
])->collapsable()->collapsedByDefault(),
79+
80+
Panel::make('How to start section', [
81+
Text::make('Heading', 'start_heading')->nullable(),
82+
Trix::make('Text', 'start_text')->nullable(),
83+
])->collapsable()->collapsedByDefault(),
84+
85+
Panel::make('Card: Community', [
86+
Text::make('Title', 'card_community_title')->nullable(),
87+
Trix::make('Text', 'card_community_text')->nullable(),
88+
Text::make('Link URL (optional)', 'card_community_link')->nullable(),
89+
Boolean::make('Open in new tab', 'card_community_new_tab'),
90+
])->collapsable()->collapsedByDefault(),
91+
92+
Panel::make('Card: Activity', [
93+
Text::make('Title', 'card_activity_title')->nullable(),
94+
Trix::make('Text', 'card_activity_text')->nullable(),
95+
Text::make('Link URL (optional)', 'card_activity_link')->nullable(),
96+
Boolean::make('Open in new tab', 'card_activity_new_tab'),
97+
])->collapsable()->collapsedByDefault(),
98+
99+
Panel::make('Card: Ambassadors', [
100+
Text::make('Title', 'card_ambassadors_title')->nullable(),
101+
Trix::make('Text', 'card_ambassadors_text')->nullable(),
102+
Text::make('Link URL (optional)', 'card_ambassadors_link')->nullable(),
103+
Boolean::make('Open in new tab', 'card_ambassadors_new_tab'),
104+
])->collapsable()->collapsedByDefault(),
105+
106+
Panel::make('Card: Stories', [
107+
Text::make('Title', 'card_stories_title')->nullable(),
108+
Trix::make('Text', 'card_stories_text')->nullable(),
109+
Text::make('Link URL (optional)', 'card_stories_link')->nullable(),
110+
Boolean::make('Open in new tab', 'card_stories_new_tab'),
111+
])->collapsable()->collapsedByDefault(),
112+
];
130113
}
131114
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
public function up(): void
10+
{
11+
if (Schema::hasTable('get_involved_page')) {
12+
return;
13+
}
14+
15+
Schema::create('get_involved_page', function (Blueprint $table) {
16+
$table->id();
17+
$table->boolean('use_dynamic_content')->default(false);
18+
19+
$table->text('intro_heading')->nullable();
20+
$table->longText('intro_text')->nullable();
21+
$table->string('intro_button_text')->nullable();
22+
$table->string('intro_button_link')->nullable();
23+
24+
$table->text('movement_heading')->nullable();
25+
$table->longText('movement_text_1')->nullable();
26+
$table->longText('movement_text_2')->nullable();
27+
28+
$table->text('start_heading')->nullable();
29+
$table->longText('start_text')->nullable();
30+
31+
$table->text('card_community_title')->nullable();
32+
$table->longText('card_community_text')->nullable();
33+
$table->string('card_community_link')->nullable();
34+
$table->boolean('card_community_new_tab')->default(false);
35+
36+
$table->text('card_activity_title')->nullable();
37+
$table->longText('card_activity_text')->nullable();
38+
$table->string('card_activity_link')->nullable();
39+
$table->boolean('card_activity_new_tab')->default(false);
40+
41+
$table->text('card_ambassadors_title')->nullable();
42+
$table->longText('card_ambassadors_text')->nullable();
43+
$table->string('card_ambassadors_link')->nullable();
44+
$table->boolean('card_ambassadors_new_tab')->default(false);
45+
46+
$table->text('card_stories_title')->nullable();
47+
$table->longText('card_stories_text')->nullable();
48+
$table->string('card_stories_link')->nullable();
49+
$table->boolean('card_stories_new_tab')->default(false);
50+
51+
$table->timestamps();
52+
});
53+
}
54+
55+
public function down(): void
56+
{
57+
Schema::dropIfExists('get_involved_page');
58+
}
59+
};

database/seeders/DatabaseSeeder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function run(): void
3131
$this->call(ResourceEditorRoleSeeder::class);
3232
$this->call(DreamJobRoleModelSeeder::class);
3333
$this->call(DreamJobsPageSeeder::class);
34+
$this->call(GetInvolvedPageSeeder::class);
3435
$this->call(HackathonsPageSeeder::class);
3536

3637
$this->call(SchoolSeeder::class);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace Database\Seeders;
4+
5+
use App\GetInvolvedPage;
6+
use Illuminate\Database\Seeder;
7+
use Illuminate\Support\Facades\Schema;
8+
9+
class GetInvolvedPageSeeder extends Seeder
10+
{
11+
public function run(): void
12+
{
13+
if (!Schema::hasTable('get_involved_page')) {
14+
return;
15+
}
16+
17+
GetInvolvedPage::firstOrCreate(
18+
['id' => 1],
19+
[
20+
'use_dynamic_content' => true,
21+
'intro_heading' => 'How to get involved',
22+
'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.',
23+
'intro_button_text' => 'Get involved',
24+
'intro_button_link' => '/guide',
25+
'movement_heading' => 'Join the movement for digital creativity',
26+
'movement_text_1' => 'The beauty of Code Week is that there’s no single way to take part. Whether you run an event or join one, you\'re helping grow a movement built on creativity, inclusion and digital skills.',
27+
'movement_text_2' => 'Spread the joy of coding, connect with like-minded people, and empower others to shape their digital future. Every action makes a difference.',
28+
'start_heading' => 'How to get started with Code Week',
29+
'start_text' => "Whether you’re curious about coding, passionate about teaching, or just want to try something new, there’s a place for you in EU Code Week.\n\nYou don’t need to be an expert. From hosting events to sharing resources, there are plenty of ways to contribute to this fun, open and collaborative movement.",
30+
'card_community_title' => 'Connect with your local Code Week community',
31+
'card_community_text' => 'Find educators, mentors and organisers near you through the Code Week map or national hubs. There’s a whole network ready to support and collaborate.',
32+
'card_community_link' => '',
33+
'card_community_new_tab' => false,
34+
'card_activity_title' => 'Register your Code Week activity',
35+
'card_activity_text' => 'Planning something? Add it to the Code Week map so others can see it.',
36+
'card_activity_link' => '',
37+
'card_activity_new_tab' => false,
38+
'card_ambassadors_title' => 'Connect with EU Code Week Ambassadors',
39+
'card_ambassadors_text' => 'Ambassadors help coordinate Code Week in their countries. Reach out for support, advice or to join local projects and challenges.',
40+
'card_ambassadors_link' => '',
41+
'card_ambassadors_new_tab' => false,
42+
'card_stories_title' => 'Share your coding experience and stories',
43+
'card_stories_text' => 'Post photos, videos and stories using #EUCodeWeek. Highlight what you’ve learned, celebrate your community, and inspire others to join',
44+
'card_stories_link' => '',
45+
'card_stories_new_tab' => false,
46+
]
47+
);
48+
}
49+
}

0 commit comments

Comments
 (0)