Banner zentral: je Website, Saison und Prioritaet, auch fuer Sonderangebote
Hinweise werden zu Bannern mit Website, Erscheinungsbildern, Prioritaet und optionalem Sonderangebot (Text, Termin und Link aus dem Angebot, sichtbar nur solange es beworben wird). Sonderangebote lassen sich mit einem Klick als Banner zeigen; die Liste nennt das heute sichtbare Banner. Banner-Texte der Erscheinungsbilder werden zu saisonalen Bannern. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
791786ed3e
commit
d2b1a853dc
21 files changed
+618
-106
No files matched your search
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Notices become the one place for the website banner: per website, limited to appearances, optionally
|
||||
* advertising a special offer (text, dates and link then come from the offer), ranked by priority.
|
||||
* Banner texts of appearances move here as banners limited to that appearance; they keep winning over
|
||||
* the existing notices as before.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('notices', function (Blueprint $table) {
|
||||
$table->string('text')->nullable()->change();
|
||||
$table->foreignId('site_id')->nullable()->after('tenant_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('special_offer_id')->nullable()->after('site_id')->constrained()->cascadeOnDelete();
|
||||
$table->json('appearance_ids')->nullable()->after('special_offer_id');
|
||||
$table->unsignedSmallInteger('priority')->default(10)->after('appearance_ids');
|
||||
});
|
||||
|
||||
foreach (DB::table('appearances')->get() as $appearance) {
|
||||
$overrides = json_decode((string) $appearance->overrides, true) ?: [];
|
||||
$banner = $overrides['banner'] ?? [];
|
||||
if (filled($banner['text'] ?? null)) {
|
||||
DB::table('notices')->insert([
|
||||
'tenant_id' => $appearance->tenant_id,
|
||||
'site_id' => $appearance->site_id,
|
||||
'appearance_ids' => json_encode([$appearance->id]),
|
||||
'priority' => 20 + (int) $appearance->priority,
|
||||
'text' => $banner['text'],
|
||||
'tone' => 'info',
|
||||
'link_label' => $banner['link_label'] ?? null,
|
||||
'link_url' => $banner['link_url'] ?? null,
|
||||
'is_active' => $appearance->is_active,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
if (array_key_exists('banner', $overrides)) {
|
||||
unset($overrides['banner']);
|
||||
DB::table('appearances')->where('id', $appearance->id)->update(['overrides' => json_encode($overrides)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('notices', function (Blueprint $table) {
|
||||
$table->dropConstrainedForeignId('special_offer_id');
|
||||
$table->dropConstrainedForeignId('site_id');
|
||||
$table->dropColumn(['appearance_ids', 'priority']);
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user