Skip to content
Merged

Dev #3512

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions app/GetInvolvedPage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class GetInvolvedPage extends Model
{
protected $table = 'get_involved_page';

protected $fillable = [
'use_dynamic_content',
'intro_heading',
'intro_text',
'intro_button_text',
'intro_button_link',
'movement_heading',
'movement_text_1',
'movement_text_2',
'start_heading',
'start_text',
'card_community_title',
'card_community_text',
'card_community_link',
'card_community_new_tab',
'card_activity_title',
'card_activity_text',
'card_activity_link',
'card_activity_new_tab',
'card_ambassadors_title',
'card_ambassadors_text',
'card_ambassadors_link',
'card_ambassadors_new_tab',
'card_stories_title',
'card_stories_text',
'card_stories_link',
'card_stories_new_tab',
];

protected $casts = [
'use_dynamic_content' => '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',
]);
}
}
139 changes: 61 additions & 78 deletions app/Nova/GetInvolvedPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('get_involved_page')) {
return;
}

Schema::create('get_involved_page', function (Blueprint $table) {
$table->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');
}
};
1 change: 1 addition & 0 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
49 changes: 49 additions & 0 deletions database/seeders/GetInvolvedPageSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Database\Seeders;

use App\GetInvolvedPage;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Schema;

class GetInvolvedPageSeeder extends Seeder
{
public function run(): void
{
if (!Schema::hasTable('get_involved_page')) {
return;
}

GetInvolvedPage::firstOrCreate(
['id' => 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,
]
);
}
}
Loading
Loading