diff --git a/app/Console/Commands/ImportLegacyStorefronts.php b/app/Console/Commands/ImportLegacyStorefronts.php index 0380f19..6dfce16 100644 --- a/app/Console/Commands/ImportLegacyStorefronts.php +++ b/app/Console/Commands/ImportLegacyStorefronts.php @@ -28,6 +28,7 @@ class ImportLegacyStorefronts extends Command {--user= : Only import for this owner (platform public_id or email)} {--refresh : Overwrite local codes that already exist (matched by short_code)} {--skip-images : Do not copy image files, only the database rows} + {--deactivate-source : After a successful import, mark the platform copy inactive so Merchant is the single source of truth (public scans still forward here via type)} {--dry-run : Report what would happen without writing anything}'; protected $description = 'Import legacy menu/shop storefronts and their products from the platform database.'; @@ -40,6 +41,7 @@ class ImportLegacyStorefronts extends Command $dry = (bool) $this->option('dry-run'); $refresh = (bool) $this->option('refresh'); $skipImages = (bool) $this->option('skip-images'); + $deactivateSource = (bool) $this->option('deactivate-source'); $platform = DB::connection('platform'); @@ -76,6 +78,7 @@ class ImportLegacyStorefronts extends Command $skipped = 0; $usersCreated = 0; $imagesCopied = 0; + $deactivated = 0; $failed = 0; foreach ($rows as $row) { @@ -165,10 +168,15 @@ class ImportLegacyStorefronts extends Command if (! $skipImages) { $imagesCopied += $this->copyImages($row->png_path, $row->svg_path, $row->payload); } + + if ($deactivateSource && $row->is_active) { + $platform->table('qr_codes')->where('id', $row->id)->update(['is_active' => 0]); + $deactivated++; + } } $this->newLine(); - $this->info("Imported: {$imported} · Skipped: {$skipped} · Local users created: {$usersCreated} · Images copied: {$imagesCopied} · Failed: {$failed}"); + $this->info("Imported: {$imported} · Skipped: {$skipped} · Local users created: {$usersCreated} · Images copied: {$imagesCopied} · Source deactivated: {$deactivated} · Failed: {$failed}"); if ($dry) { $this->comment('Dry run — no changes were written.');