Add homepage announcement module

This commit is contained in:
2026-05-01 11:43:08 +02:00
parent 961d21e91e
commit 874f8feb9c
16 changed files with 2968 additions and 2 deletions

View File

@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('homepage_announcements', function (Blueprint $table): void {
$table->id();
$table->string('title', 180);
$table->string('subtitle', 255)->nullable();
$table->string('badge_text', 100)->nullable();
$table->longText('content_html')->nullable();
$table->string('type', 40)->default('announcement');
$table->string('status', 40)->default('draft');
$table->boolean('is_active')->default(true);
$table->dateTime('starts_at')->nullable();
$table->dateTime('ends_at')->nullable();
$table->string('primary_link_label', 80)->nullable();
$table->string('primary_link_type', 40)->nullable();
$table->string('primary_link_url', 2048)->nullable();
$table->string('primary_link_target_type', 40)->nullable();
$table->unsignedBigInteger('primary_link_target_id')->nullable();
$table->string('secondary_link_label', 80)->nullable();
$table->string('secondary_link_type', 40)->nullable();
$table->string('secondary_link_url', 2048)->nullable();
$table->string('secondary_link_target_type', 40)->nullable();
$table->unsignedBigInteger('secondary_link_target_id')->nullable();
$table->string('background_type', 40)->nullable();
$table->string('background_image', 2048)->nullable();
$table->string('gradient_preset', 80)->nullable();
$table->string('theme_preset', 80)->nullable();
$table->string('text_color', 32)->nullable();
$table->unsignedTinyInteger('overlay_opacity')->nullable();
$table->string('placement', 80)->default('homepage_after_featured');
$table->integer('priority')->default(0);
$table->boolean('is_dismissible')->default(true);
$table->unsignedInteger('dismiss_version')->default(1);
$table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
$table->foreignId('updated_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->softDeletes();
$table->index('status');
$table->index('is_active');
$table->index('starts_at');
$table->index('ends_at');
$table->index('placement');
$table->index('priority');
$table->index(['placement', 'status', 'is_active', 'priority'], 'homepage_announcements_surface_idx');
});
}
public function down(): void
{
Schema::dropIfExists('homepage_announcements');
}
};

View File

@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
namespace Database\Seeders;
use App\Models\HomepageAnnouncement;
use Illuminate\Database\Seeder;
use Illuminate\Support\Carbon;
use cPad\Plugins\News\Models\NewsArticle;
final class HomepageAnnouncementLaunchSeeder extends Seeder
{
public function run(): void
{
$launchStory = NewsArticle::query()->firstWhere('slug', 'skinbase-nova-is-live');
HomepageAnnouncement::query()->updateOrCreate(
[
'placement' => HomepageAnnouncement::PLACEMENT_HOMEPAGE_AFTER_FEATURED,
'type' => HomepageAnnouncement::TYPE_LAUNCH,
'title' => 'Skinbase Nova is live.',
],
[
'subtitle' => 'A new chapter for the Skinbase creative community.',
'badge_text' => 'Launch Day · 1 May 2026',
'content_html' => implode("\n", [
'<p><strong>Today, 1 May 2026, Skinbase begins a new chapter.</strong></p>',
'<p>Skinbase Nova is a modern reboot of our creative community for digital art, wallpapers, skins, photography, customization, and discovery.</p>',
'<p>We are bringing the spirit of classic Skinbase into a faster, cleaner, and more modern experience — built for creators, fans, and the future.</p>',
'<p>Welcome to <strong>Skinbase Nova</strong>.</p>',
]),
'status' => HomepageAnnouncement::STATUS_PUBLISHED,
'is_active' => true,
'starts_at' => Carbon::create(2026, 5, 1, 0, 0, 0),
'ends_at' => null,
'primary_link_label' => 'Explore Nova',
'primary_link_type' => HomepageAnnouncement::LINK_TYPE_EXPLORE,
'primary_link_url' => '/explore',
'primary_link_target_type' => null,
'primary_link_target_id' => null,
'secondary_link_label' => $launchStory ? 'Read the launch story' : null,
'secondary_link_type' => $launchStory ? HomepageAnnouncement::LINK_TYPE_NEWS : HomepageAnnouncement::LINK_TYPE_NONE,
'secondary_link_url' => $launchStory ? null : null,
'secondary_link_target_type' => $launchStory ? HomepageAnnouncement::LINK_TYPE_NEWS : null,
'secondary_link_target_id' => $launchStory?->id,
'background_type' => null,
'background_image' => null,
'gradient_preset' => HomepageAnnouncement::GRADIENT_NOVA_AURORA,
'theme_preset' => 'launch',
'text_color' => null,
'overlay_opacity' => 55,
'priority' => 100,
'is_dismissible' => true,
'dismiss_version' => 1,
]
);
}
}