10-04-2026
This commit is contained in:
parent
4d6b4930b2
commit
4bb89aad8c
836 changed files with 52961 additions and 5950 deletions
86
app/Console/Commands/MigrateLegacyDisplays.php
Normal file
86
app/Console/Commands/MigrateLegacyDisplays.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Display;
|
||||
use App\Models\DisplayFooterContent;
|
||||
use App\Models\DisplayVersion;
|
||||
use App\Models\DisplayVersionItem;
|
||||
use App\Models\DisplayVideo;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class MigrateLegacyDisplays extends Command
|
||||
{
|
||||
protected $signature = 'display:migrate-legacy';
|
||||
|
||||
protected $description = 'Migrate existing DisplayVideo/DisplayFooterContent data into the new DisplayVersion system';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
if (DisplayVersion::where('name', 'Video-Display (Legacy)')->exists()) {
|
||||
$this->warn('Legacy migration already executed. Skipping.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$videos = DisplayVideo::orderBy('sort_order')->get();
|
||||
$footers = DisplayFooterContent::orderBy('sort_order')->get();
|
||||
|
||||
if ($videos->isEmpty() && $footers->isEmpty()) {
|
||||
$this->info('No legacy data found. Nothing to migrate.');
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$version = DisplayVersion::create([
|
||||
'name' => 'Video-Display (Legacy)',
|
||||
'type' => 'video-display',
|
||||
'settings' => [],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$sortOrder = 0;
|
||||
foreach ($videos as $video) {
|
||||
DisplayVersionItem::create([
|
||||
'display_version_id' => $version->id,
|
||||
'item_type' => 'video',
|
||||
'content' => [
|
||||
'filename' => $video->filename,
|
||||
'title' => $video->title,
|
||||
'position' => $video->position,
|
||||
],
|
||||
'sort_order' => $sortOrder++,
|
||||
'is_active' => $video->is_active,
|
||||
]);
|
||||
}
|
||||
|
||||
$sortOrder = 0;
|
||||
foreach ($footers as $footer) {
|
||||
DisplayVersionItem::create([
|
||||
'display_version_id' => $version->id,
|
||||
'item_type' => 'footer',
|
||||
'content' => [
|
||||
'headline' => $footer->headline,
|
||||
'subline' => $footer->subline,
|
||||
'url' => $footer->url,
|
||||
],
|
||||
'sort_order' => $sortOrder++,
|
||||
'is_active' => $footer->is_active,
|
||||
]);
|
||||
}
|
||||
|
||||
$display = Display::create([
|
||||
'name' => 'Hauptdisplay',
|
||||
'location' => 'Schaufenster',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$display->versions()->attach($version->id, ['sort_order' => 0]);
|
||||
|
||||
$this->info("Migrated {$videos->count()} videos and {$footers->count()} footer items.");
|
||||
$this->info("Created version: {$version->name} (ID: {$version->id})");
|
||||
$this->info("Created display: {$display->name} (ID: {$display->id})");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue