Skip to content

Commit 3e2fff2

Browse files
authored
Merge pull request #3524 from codeeu/dev
Enable Council Presidency content management in Nova
2 parents 0305c2d + 0c9ba46 commit 3e2fff2

5 files changed

Lines changed: 64 additions & 18 deletions

File tree

app/Livewire/PartnerContentComponent.php

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,36 @@ private function getAllPartners()
591591
return collect(self::$defaultPartnersRaw);
592592
}
593593

594+
private function getCouncilMembers()
595+
{
596+
$fromDb = Partner::active()
597+
->ordered()
598+
->whereJsonContains('categories', 'Council Presidency')
599+
->get();
600+
601+
if ($fromDb->isNotEmpty()) {
602+
return $fromDb->map(function (Partner $member) {
603+
$obj = $member->toPartnerObject();
604+
$obj->title = $member->title ?: 'Council President';
605+
$obj->image = $member->main_img_url ?: $member->logo_url;
606+
607+
return $obj;
608+
});
609+
}
610+
611+
return collect([
612+
(object) [
613+
'name' => 'Annie Bergh – Sweden',
614+
'title' => 'Council President',
615+
'description' => 'Building bridges between classrooms and code
616+
Annie Bergh began her educational journey in 1991 as a preschool teacher and later taught students aged 6 to 13. But since 2014, she’s taken on a broader mission: supporting all 85 schools in Malmö municipality as a driving force behind internationalisation, coding, and robotics. Annie is the proud caretaker of 17 NAO robots—yes, actual humanoid robots—which teachers across Malmö can borrow to bring coding and AI to life in their classrooms. Through hands-on workshops and energetic TeachMeets, she inspires educators from preschool to upper secondary to integrate technology into their teaching in meaningful and creative ways.
617+
Until recently, Annie also led the regional First Lego League (FLL) initiative for eight years, helping young minds explore science and innovation through teamwork and robotics. While she no longer teaches in a classroom, she’s still very much an educator—just one with a few more robots and a lot more cables.
618+
My motto in the presidency is: Innovate, educate, collaborate: Together, I know that we can build a brighter, more collaborative future through the power of code.',
619+
'image' => 'images/council/AnnieBergh.jpg',
620+
],
621+
]);
622+
}
623+
594624
/**
595625
* Return default partners as array of arrays (for seeding into DB). Call after getAllPartners() or ensure defaults are loaded.
596626
*/
@@ -605,22 +635,9 @@ public static function getDefaultPartnersForSeeding(): array
605635
public function render()
606636
{
607637
if ($this->filter === 'Council Presidency') {
608-
// Council Presidency content
609-
$councilContent = collect([
610-
(object)[
611-
'name' => 'Annie Bergh – Sweden',
612-
'title' => 'Council President',
613-
'description' => 'Building bridges between classrooms and code
614-
Annie Bergh began her educational journey in 1991 as a preschool teacher and later taught students aged 6 to 13. But since 2014, she’s taken on a broader mission: supporting all 85 schools in Malmö municipality as a driving force behind internationalisation, coding, and robotics. Annie is the proud caretaker of 17 NAO robots—yes, actual humanoid robots—which teachers across Malmö can borrow to bring coding and AI to life in their classrooms. Through hands-on workshops and energetic TeachMeets, she inspires educators from preschool to upper secondary to integrate technology into their teaching in meaningful and creative ways.
615-
Until recently, Annie also led the regional First Lego League (FLL) initiative for eight years, helping young minds explore science and innovation through teamwork and robotics. While she no longer teaches in a classroom, she’s still very much an educator—just one with a few more robots and a lot more cables.
616-
My motto in the presidency is: Innovate, educate, collaborate: Together, I know that we can build a brighter, more collaborative future through the power of code.',
617-
'image' => 'images/council/AnnieBergh.jpg',
618-
],
619-
]);
620-
621638
// Render the Council Presidency content view
622639
return view('livewire.council-content-component', [
623-
'councilMembers' => $councilContent
640+
'councilMembers' => $this->getCouncilMembers(),
624641
]);
625642
}
626643

app/Nova/Partner.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ public function fields(Request $request): array
4545
->nullable()
4646
->help('Display name. Optional for sponsor logos (e.g. EU Code Week Supporters).'),
4747

48+
Text::make('Title', 'title')
49+
->nullable()
50+
->help('Used in the Council Presidency tab (e.g. "Council President").'),
51+
4852
Text::make('Logo URL', 'logo_url')
4953
->rules('required')
5054
->help('Path from site root, e.g. images/partners/logo.png (no leading slash), or full URL.'),
@@ -53,8 +57,9 @@ public function fields(Request $request): array
5357
->options([
5458
'Partners' => 'Partners',
5559
'Sponsor' => 'EU Code Week Supporters (Sponsor)',
60+
'Council Presidency' => 'Council Presidency',
5661
])
57-
->help('Partners = "Partners" tab; Sponsor = "EU Code Week Supporters" tab.')
62+
->help('Partners = "Partners" tab; Sponsor = "EU Code Week Supporters" tab; Council Presidency = "Council Presidency" tab.')
5863
->resolveUsing(function ($value) {
5964
$arr = is_array($value) ? $value : (array) json_decode($value ?? '[]', true);
6065
return $arr[0] ?? null;
@@ -74,7 +79,7 @@ public function fields(Request $request): array
7479

7580
Text::make('Main image URL', 'main_img_url')
7681
->nullable()
77-
->help('Larger image path (optional).'),
82+
->help('Larger image path (optional). Used as profile image for Council Presidency.'),
7883

7984
Number::make('Position', 'position')
8085
->min(0)

app/Partner.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class Partner extends Model
88
{
99
protected $fillable = [
1010
'name',
11+
'title',
1112
'logo_url',
1213
'categories',
1314
'description',
@@ -41,6 +42,7 @@ public function toPartnerObject(): \stdClass
4142
$o = new \stdClass;
4243
$o->id = $this->id;
4344
$o->name = $this->name;
45+
$o->title = $this->title;
4446
$o->logo_url = $this->logo_url;
4547
$o->categories = $this->categories ?? [];
4648
$o->description = $this->description;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
Schema::table('partners', function (Blueprint $table) {
12+
$table->string('title')->nullable()->after('name');
13+
});
14+
}
15+
16+
public function down(): void
17+
{
18+
Schema::table('partners', function (Blueprint $table) {
19+
$table->dropColumn('title');
20+
});
21+
}
22+
};

resources/views/livewire/council-content-component.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<img
1717
src="{{ $member->image }}"
18-
alt="Portrait of Stamatis Papadakis, EU Code Week Council President"
18+
alt="Portrait of {{ $member->name }}"
1919
class="object-cover h-full max-h-[396px] w-full mt-6 md:hidden block rounded-[12px]"
2020
/>
2121

@@ -59,7 +59,7 @@ class="object-cover h-full max-h-[396px] w-full mt-6 md:hidden block rounded-[12
5959
<aside class="flex justify-center items-center max-md:max-w-full" aria-label="Profile image">
6060
<img
6161
src="{{ $member->image }}"
62-
alt="Portrait of Stamatis Papadakis, EU Code Week Council President"
62+
alt="Portrait of {{ $member->name }}"
6363
class="object-contain md:object-cover w-full max-w-[643px] h-full max-h-[646px] max-md:hidden block rounded-[12px]"
6464
/>
6565
</aside>

0 commit comments

Comments
 (0)