Skip to content
Merged

Dev #3303

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
13 changes: 9 additions & 4 deletions app/HomeSlide.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class HomeSlide extends Model
'description',
'url',
'button_text',
'open_primary_new_tab',
'url2',
'button2_text',
'open_second_new_tab',
'image',
'position',
'active',
Expand All @@ -25,6 +27,8 @@ class HomeSlide extends Model
'show_countdown' => 'boolean',
'countdown_target' => 'datetime',
'position' => 'integer',
'open_primary_new_tab' => 'boolean',
'open_second_new_tab' => 'boolean',
];

public function scopeActive($query)
Expand All @@ -38,16 +42,17 @@ public function scopeOrdered($query)
}

/**
* Full URL for image (prefix with base URL if stored as path).
* Full URL for image. Use asset() for paths so images in public/ resolve correctly.
*/
public function getImageUrlAttribute(): ?string
{
if (empty($this->image)) {
return null;
}
if (str_starts_with($this->image, 'http://') || str_starts_with($this->image, 'https://')) {
return $this->image;
$value = trim($this->image);
if (str_starts_with($value, 'http://') || str_starts_with($value, 'https://')) {
return $value;
}
return url(ltrim($this->image, '/'));
return asset(ltrim($value, '/'));
}
}
10 changes: 10 additions & 0 deletions app/Http/Controllers/HomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ private function getActivities()
'description' => $slide->description ?? '',
'url' => $slide->url,
'btn_lang' => $slide->button_text,
'open_primary_new_tab' => $slide->open_primary_new_tab ?? false,
'url2' => $slide->url2,
'btn2_lang' => $slide->button2_text,
'open_second_new_tab' => $slide->open_second_new_tab ?? false,
'image' => $slide->image_url,
'show_countdown' => $slide->show_countdown,
'countdown_target' => $slide->countdown_target?->toIso8601String(),
Expand All @@ -54,8 +56,10 @@ private function getActivities()
'description' => 'home.banner5_description',
'url' => '/future-ready-csr',
'btn_lang' => 'home.learn_more',
'open_primary_new_tab' => false,
'url2' => null,
'btn2_lang' => null,
'open_second_new_tab' => false,
'image' => $defaultImages[0] ?? null,
'show_countdown' => false,
'countdown_target' => null,
Expand All @@ -65,8 +69,10 @@ private function getActivities()
'description' => 'home.banner4_description',
'url' => 'https://codeweek.eu/blog/code-week-digital-educator-awards-2025/',
'btn_lang' => 'home.view_winners',
'open_primary_new_tab' => false,
'url2' => 'https://codeweek.eu/blog/code-week-digital-educator-awards-2025/',
'btn2_lang' => null,
'open_second_new_tab' => false,
'image' => $defaultImages[1] ?? null,
'show_countdown' => false,
'countdown_target' => null,
Expand All @@ -76,8 +82,10 @@ private function getActivities()
'description' => 'home.banner6_description',
'url' => 'https://airtable.com/appW5W6DJ6CI6SVdH/pagLDrU2NQja9F2vu/form',
'btn_lang' => 'home.register_here',
'open_primary_new_tab' => false,
'url2' => null,
'btn2_lang' => null,
'open_second_new_tab' => false,
'image' => $defaultImages[2] ?? null,
'show_countdown' => false,
'countdown_target' => null,
Expand All @@ -87,8 +95,10 @@ private function getActivities()
'description' => 'home.when_text',
'url' => '/guide',
'btn_lang' => 'home.get_involved',
'open_primary_new_tab' => false,
'url2' => '/blog/code-week-25-programme/',
'btn2_lang' => null,
'open_second_new_tab' => false,
'image' => $defaultImages[3] ?? null,
'show_countdown' => false,
'countdown_target' => null,
Expand Down
14 changes: 9 additions & 5 deletions app/Nova/HomeSlide.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,25 @@ public function fields(Request $request): array
ID::make()->sortable(),
Text::make('Title', 'title')
->rules('required')
->help('Lang key (e.g. home.banner1_title) or plain text.'),
->help('Use a lang key (e.g. home.banner1_title) for translated content, or type plain text.'),
Textarea::make('Description', 'description')
->nullable()
->help('Lang key or plain text.'),
->help('Use a lang key for translated content, or plain text.'),
Text::make('Primary button URL', 'url')->rules('required')->hideFromIndex(),
Text::make('Primary button label', 'button_text')
->rules('required')
->help('Lang key (e.g. home.learn_more) or plain text.'),
->help('Lang key (e.g. home.learn_more) for translation, or plain text.'),
Boolean::make('Open primary link in new tab', 'open_primary_new_tab')
->help('Open the primary button link in a new window/tab.'),
Text::make('Second button URL', 'url2')->nullable()->hideFromIndex(),
Text::make('Second button label', 'button2_text')
->nullable()
->help('Leave empty to hide second button.'),
->help('Leave empty to hide second button. Use lang key for translation.'),
Boolean::make('Open second link in new tab', 'open_second_new_tab')
->help('Open the second button link in a new window/tab.'),
Text::make('Image', 'image')
->nullable()
->help('Path e.g. /images/homepage/slide1.png or full URL. Used as slide background.'),
->help('Path from site root e.g. images/dream-jobs/dream_jobs_bg.png (no leading slash), or full URL. Used as slide background.'),
Number::make('Position', 'position')
->min(0)
->default(0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

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

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('home_slides', function (Blueprint $table) {
$table->boolean('open_primary_new_tab')->default(false)->after('button_text');
$table->boolean('open_second_new_tab')->default(false)->after('button2_text');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('home_slides', function (Blueprint $table) {
$table->dropColumn(['open_primary_new_tab', 'open_second_new_tab']);
});
}
};
14 changes: 8 additions & 6 deletions resources/views/static/home.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,22 +90,24 @@ function countdownTimer(targetDate) {

<h2
class="text-[#1C4DA1] text-[30px] md:text-[60px] leading-9 md:leading-[72px] font-normal font-['Montserrat'] mb-4 max-w-[525px]">
@lang($activity['title'])
{{ __($activity['title']) }}
</h2>
<p
class="text-xl md:text-2xl leading-8 text-[#333E48] p-0 mb-4 max-md:max-w-full max-w-[525px]">
{{ strip_tags(__($activity['description'] ?? '')) }}
</p>
<div class="flex flex-col space-y-4 md:flex-row md:space-x-4 md:space-y-0">
<a class="inline-block bg-primary hover:bg-hover-orange rounded-full py-4 px-6 md:px-10 font-semibold text-base w-full md:w-auto text-center text-[#20262C] transition-all duration-300"
href="{{ $activity['url'] }}">
@lang($activity['btn_lang'])
href="{{ $activity['url'] }}"
@if(!empty($activity['open_primary_new_tab'])) target="_blank" rel="noopener noreferrer" @endif>
{{ __($activity['btn_lang']) }}
</a>

@if (isset($activity['btn2_lang']) && !is_null($activity['btn2_lang']))
@if (isset($activity['btn2_lang']) && !is_null($activity['btn2_lang']) && $activity['btn2_lang'] !== '')
<a class="flex justify-center items-center gap-2 text-[#1C4DA1] border-solid border-2 border-[#1C4DA1] rounded-full py-3 px-8 font-semibold text-lg transition-all duration-300 hover:bg-[#E8EDF6] group"
target="_blank" href="{{ $activity['url2'] }}">
<span>@lang($activity['btn2_lang'])</span>
href="{{ $activity['url2'] }}"
@if(!empty($activity['open_second_new_tab'])) target="_blank" rel="noopener noreferrer" @endif>
<span>{{ __($activity['btn2_lang']) }}</span>
<div class="flex overflow-hidden gap-2 w-4">
<img src="/images/arrow-right-icon.svg"
class="duration-500 transform -translate-x-6 min-w-4 group-hover:translate-x-0" />
Expand Down
Loading