From f2c806ee66f5a1b620e300d7bccfe520cfb6abda Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Wed, 15 Apr 2026 11:41:36 +0100 Subject: [PATCH] qc changes --- app/GetInvolvedPage.php | 60 ++++++++ app/Nova/GetInvolvedPage.php | 139 ++++++++---------- ..._120000_create_get_involved_page_table.php | 59 ++++++++ database/seeders/DatabaseSeeder.php | 1 + database/seeders/GetInvolvedPageSeeder.php | 49 ++++++ resources/views/static/get-involved.blade.php | 109 +++++++++----- 6 files changed, 300 insertions(+), 117 deletions(-) create mode 100644 app/GetInvolvedPage.php create mode 100644 database/migrations/2026_04_15_120000_create_get_involved_page_table.php create mode 100644 database/seeders/GetInvolvedPageSeeder.php diff --git a/app/GetInvolvedPage.php b/app/GetInvolvedPage.php new file mode 100644 index 000000000..cb36d9b28 --- /dev/null +++ b/app/GetInvolvedPage.php @@ -0,0 +1,60 @@ + 'boolean', + 'card_community_new_tab' => 'boolean', + 'card_activity_new_tab' => 'boolean', + 'card_ambassadors_new_tab' => 'boolean', + 'card_stories_new_tab' => 'boolean', + ]; + + public static function config(): self + { + $page = self::first(); + if ($page) { + return $page; + } + + return self::create([ + 'use_dynamic_content' => false, + 'intro_button_link' => '/guide', + ]); + } +} diff --git a/app/Nova/GetInvolvedPage.php b/app/Nova/GetInvolvedPage.php index dce6e9412..2decc8f63 100644 --- a/app/Nova/GetInvolvedPage.php +++ b/app/Nova/GetInvolvedPage.php @@ -5,18 +5,18 @@ use Illuminate\Http\Request; use Laravel\Nova\Fields\Boolean; use Laravel\Nova\Fields\ID; -use Laravel\Nova\Fields\Select; use Laravel\Nova\Fields\Text; -use Laravel\Nova\Fields\Textarea; +use Laravel\Nova\Fields\Trix; use Laravel\Nova\Http\Requests\NovaRequest; +use Laravel\Nova\Panel; class GetInvolvedPage extends Resource { public static $group = 'Content'; - public static $model = \App\StaticPage::class; + public static $model = \App\GetInvolvedPage::class; - public static $title = 'name'; + public static $title = 'id'; public static $priority = 10; @@ -42,90 +42,73 @@ public static function authorizedToViewAny(Request $request): bool public static function indexQuery(NovaRequest $request, $query) { - return $query->where('path', '/get-involved')->orWhere('unique_identifier', 'get-involved'); + return $query->where('id', 1); } public static function relatableQuery(NovaRequest $request, $query) { - return $query->where('path', '/get-involved')->orWhere('unique_identifier', 'get-involved'); - } - - public function fields(Request $request): array - { - return [ - ID::make()->sortable(), - - Text::make('Name') - ->sortable() - ->rules('required', 'max:255'), - - Boolean::make('Is Searchable', 'is_searchable'), - - Select::make('Category') - ->options([ - 'General' => 'General', - 'Challenges' => 'Challenges', - 'Tranning' => 'Tranning', - 'Online Courses' => 'Online Courses', - 'Other' => 'Other', - ]) - ->nullable() - ->displayUsingLabels(), - - Select::make('Link Type', 'link_type') - ->options([ - 'internal_link' => 'Internal Link', - 'external_link' => 'External Link', - ]) - ->rules('required') - ->displayUsingLabels(), - - Textarea::make('Description')->nullable(), - - Text::make('Language') - ->sortable() - ->rules('required', 'size:2') - ->default('en'), - - Text::make('Unique Identifier') - ->rules('required', 'unique:static_pages,unique_identifier,{{resourceId}}'), - - Text::make('Path') - ->readonly() - ->rules('required', 'unique:static_pages,path,{{resourceId}}'), - - Text::make('Keywords') - ->rules('nullable') - ->help('Enter keywords separated by commas, e.g., coding, education, technology.'), - - Text::make('Thumbnail')->nullable(), - - Text::make('Meta Title')->nullable(), - - Textarea::make('Meta Description')->nullable(), - - Textarea::make('Meta Keywords')->nullable(), - ]; + return $query->where('id', 1); } public static function authorizedToCreate(Request $request): bool { - return true; + return false; } - public static function redirectAfterCreate(NovaRequest $request, $resource) - { - return '/resources/' . static::uriKey() . '/' . $resource->id; - } - - public static function fill(NovaRequest $request, $model) + public function fields(Request $request): array { - $model->path = $model->path ?: '/get-involved'; - $model->unique_identifier = $model->unique_identifier ?: 'get-involved'; - $model->language = $model->language ?: 'en'; - $model->link_type = $model->link_type ?: 'internal_link'; - $model->name = $model->name ?: 'Get Involved'; - - return parent::fill($request, $model); + return [ + ID::make()->onlyOnForms(), + + Panel::make('General', [ + Boolean::make('Use dynamic content for this page', 'use_dynamic_content'), + ])->collapsable()->collapsedByDefault(), + + Panel::make('Hero', [ + Text::make('Heading', 'intro_heading')->nullable(), + Trix::make('Intro text', 'intro_text')->nullable(), + Text::make('Button text', 'intro_button_text')->nullable(), + Text::make('Button link', 'intro_button_link')->nullable(), + ])->collapsable()->collapsedByDefault(), + + Panel::make('Movement section', [ + Text::make('Heading', 'movement_heading')->nullable(), + Trix::make('Paragraph 1', 'movement_text_1')->nullable(), + Trix::make('Paragraph 2', 'movement_text_2')->nullable(), + ])->collapsable()->collapsedByDefault(), + + Panel::make('How to start section', [ + Text::make('Heading', 'start_heading')->nullable(), + Trix::make('Text', 'start_text')->nullable(), + ])->collapsable()->collapsedByDefault(), + + Panel::make('Card: Community', [ + Text::make('Title', 'card_community_title')->nullable(), + Trix::make('Text', 'card_community_text')->nullable(), + Text::make('Link URL (optional)', 'card_community_link')->nullable(), + Boolean::make('Open in new tab', 'card_community_new_tab'), + ])->collapsable()->collapsedByDefault(), + + Panel::make('Card: Activity', [ + Text::make('Title', 'card_activity_title')->nullable(), + Trix::make('Text', 'card_activity_text')->nullable(), + Text::make('Link URL (optional)', 'card_activity_link')->nullable(), + Boolean::make('Open in new tab', 'card_activity_new_tab'), + ])->collapsable()->collapsedByDefault(), + + Panel::make('Card: Ambassadors', [ + Text::make('Title', 'card_ambassadors_title')->nullable(), + Trix::make('Text', 'card_ambassadors_text')->nullable(), + Text::make('Link URL (optional)', 'card_ambassadors_link')->nullable(), + Boolean::make('Open in new tab', 'card_ambassadors_new_tab'), + ])->collapsable()->collapsedByDefault(), + + Panel::make('Card: Stories', [ + Text::make('Title', 'card_stories_title')->nullable(), + Trix::make('Text', 'card_stories_text')->nullable(), + Text::make('Link URL (optional)', 'card_stories_link')->nullable(), + Boolean::make('Open in new tab', 'card_stories_new_tab'), + ])->collapsable()->collapsedByDefault(), + ]; } } diff --git a/database/migrations/2026_04_15_120000_create_get_involved_page_table.php b/database/migrations/2026_04_15_120000_create_get_involved_page_table.php new file mode 100644 index 000000000..a43476687 --- /dev/null +++ b/database/migrations/2026_04_15_120000_create_get_involved_page_table.php @@ -0,0 +1,59 @@ +id(); + $table->boolean('use_dynamic_content')->default(false); + + $table->text('intro_heading')->nullable(); + $table->longText('intro_text')->nullable(); + $table->string('intro_button_text')->nullable(); + $table->string('intro_button_link')->nullable(); + + $table->text('movement_heading')->nullable(); + $table->longText('movement_text_1')->nullable(); + $table->longText('movement_text_2')->nullable(); + + $table->text('start_heading')->nullable(); + $table->longText('start_text')->nullable(); + + $table->text('card_community_title')->nullable(); + $table->longText('card_community_text')->nullable(); + $table->string('card_community_link')->nullable(); + $table->boolean('card_community_new_tab')->default(false); + + $table->text('card_activity_title')->nullable(); + $table->longText('card_activity_text')->nullable(); + $table->string('card_activity_link')->nullable(); + $table->boolean('card_activity_new_tab')->default(false); + + $table->text('card_ambassadors_title')->nullable(); + $table->longText('card_ambassadors_text')->nullable(); + $table->string('card_ambassadors_link')->nullable(); + $table->boolean('card_ambassadors_new_tab')->default(false); + + $table->text('card_stories_title')->nullable(); + $table->longText('card_stories_text')->nullable(); + $table->string('card_stories_link')->nullable(); + $table->boolean('card_stories_new_tab')->default(false); + + $table->timestamps(); + }); + } + + public function down(): void + { + Schema::dropIfExists('get_involved_page'); + } +}; diff --git a/database/seeders/DatabaseSeeder.php b/database/seeders/DatabaseSeeder.php index 0761fcced..7ffb504a4 100755 --- a/database/seeders/DatabaseSeeder.php +++ b/database/seeders/DatabaseSeeder.php @@ -31,6 +31,7 @@ public function run(): void $this->call(ResourceEditorRoleSeeder::class); $this->call(DreamJobRoleModelSeeder::class); $this->call(DreamJobsPageSeeder::class); + $this->call(GetInvolvedPageSeeder::class); $this->call(HackathonsPageSeeder::class); $this->call(SchoolSeeder::class); diff --git a/database/seeders/GetInvolvedPageSeeder.php b/database/seeders/GetInvolvedPageSeeder.php new file mode 100644 index 000000000..7f80ea48b --- /dev/null +++ b/database/seeders/GetInvolvedPageSeeder.php @@ -0,0 +1,49 @@ + 1], + [ + 'use_dynamic_content' => true, + 'intro_heading' => 'How to get involved', + '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.', + 'intro_button_text' => 'Get involved', + 'intro_button_link' => '/guide', + 'movement_heading' => 'Join the movement for digital creativity', + '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.', + '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.', + 'start_heading' => 'How to get started with Code Week', + '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.", + 'card_community_title' => 'Connect with your local Code Week community', + '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.', + 'card_community_link' => '', + 'card_community_new_tab' => false, + 'card_activity_title' => 'Register your Code Week activity', + 'card_activity_text' => 'Planning something? Add it to the Code Week map so others can see it.', + 'card_activity_link' => '', + 'card_activity_new_tab' => false, + 'card_ambassadors_title' => 'Connect with EU Code Week Ambassadors', + 'card_ambassadors_text' => 'Ambassadors help coordinate Code Week in their countries. Reach out for support, advice or to join local projects and challenges.', + 'card_ambassadors_link' => '', + 'card_ambassadors_new_tab' => false, + 'card_stories_title' => 'Share your coding experience and stories', + 'card_stories_text' => 'Post photos, videos and stories using #EUCodeWeek. Highlight what you’ve learned, celebrate your community, and inspire others to join', + 'card_stories_link' => '', + 'card_stories_new_tab' => false, + ] + ); + } +} diff --git a/resources/views/static/get-involved.blade.php b/resources/views/static/get-involved.blade.php index c2119c06d..7f5de6d43 100644 --- a/resources/views/static/get-involved.blade.php +++ b/resources/views/static/get-involved.blade.php @@ -5,6 +5,10 @@ @php $list = [(object) ['label' => 'Get Involved', 'href' => '']]; + $hasGetInvolvedPageTable = \Illuminate\Support\Facades\Schema::hasTable('get_involved_page'); + $page = $hasGetInvolvedPageTable ? \App\GetInvolvedPage::config() : null; + $dynamic = $page && $page->use_dynamic_content; + $optionalValue = static function (string $key): ?string { $value = __($key); @@ -42,6 +46,33 @@ 'ambassadors' => $makeCardLink('ambassadors'), 'stories' => $makeCardLink('stories'), ]; + + $cardData = [ + 'community' => [ + 'title' => $dynamic && $page && $page->card_community_title ? $page->card_community_title : 'Connect with your local Code Week community', + 'text' => $dynamic && $page && $page->card_community_text ? $page->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.', + 'href' => $dynamic && $page && $page->card_community_link ? $page->card_community_link : $engagementLinks['community']['href'], + 'new_tab' => $dynamic && $page ? (bool) $page->card_community_new_tab : ($engagementLinks['community']['target'] === '_blank'), + ], + 'activity' => [ + 'title' => $dynamic && $page && $page->card_activity_title ? $page->card_activity_title : 'Register your Code Week activity', + 'text' => $dynamic && $page && $page->card_activity_text ? $page->card_activity_text : 'Planning something? Add it to the Code Week map so others can see it.', + 'href' => $dynamic && $page && $page->card_activity_link ? $page->card_activity_link : $engagementLinks['activity']['href'], + 'new_tab' => $dynamic && $page ? (bool) $page->card_activity_new_tab : ($engagementLinks['activity']['target'] === '_blank'), + ], + 'ambassadors' => [ + 'title' => $dynamic && $page && $page->card_ambassadors_title ? $page->card_ambassadors_title : 'Connect with EU Code Week Ambassadors', + 'text' => $dynamic && $page && $page->card_ambassadors_text ? $page->card_ambassadors_text : 'Ambassadors help coordinate Code Week in their countries. Reach out for support, advice or to join local projects and challenges.', + 'href' => $dynamic && $page && $page->card_ambassadors_link ? $page->card_ambassadors_link : $engagementLinks['ambassadors']['href'], + 'new_tab' => $dynamic && $page ? (bool) $page->card_ambassadors_new_tab : ($engagementLinks['ambassadors']['target'] === '_blank'), + ], + 'stories' => [ + 'title' => $dynamic && $page && $page->card_stories_title ? $page->card_stories_title : 'Share your coding experience and stories', + 'text' => $dynamic && $page && $page->card_stories_text ? $page->card_stories_text : 'Post photos, videos and stories using #EUCodeWeek. Highlight what you’ve learned, celebrate your community, and inspire others to join', + 'href' => $dynamic && $page && $page->card_stories_link ? $page->card_stories_link : $engagementLinks['stories']['href'], + 'new_tab' => $dynamic && $page ? (bool) $page->card_stories_new_tab : ($engagementLinks['stories']['target'] === '_blank'), + ], + ]; @endphp @section('layout.breadcrumb') @@ -71,15 +102,15 @@ class="flex flex-col-reverse justify-between items-center mx-auto w-full max-md: class="px-6 py-10 md:px-14 md:py-[4.5rem] bg-white rounded-[32px] z-10 w-fit h-fit relative -top-6">

- @lang('cw2020.get-involved.title') + {{ $dynamic && $page && $page->intro_heading ? $page->intro_heading : __('cw2020.get-involved.title') }}

- 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. + {{ $dynamic && $page && $page->intro_text ? $page->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.' }}

- Get involved + href="{{ $dynamic && $page && $page->intro_button_link ? $page->intro_button_link : '/guide' }}"> + {{ $dynamic && $page && $page->intro_button_text ? $page->intro_button_text : 'Get involved' }}