option('dry-run'); $force = $this->option('force'); $activeLayout = config('netgescon.active_layout', 'admin.layouts.netgescon'); $deprecatedLayouts = config('netgescon.deprecated_layouts', []); $this->info("๐Ÿ” Scansione file Blade per layout deprecati..."); $this->info("Layout attivo: {$activeLayout}"); $this->info("Layout deprecati: " . implode(', ', $deprecatedLayouts)); $files = File::allFiles(resource_path('views')); $changedFiles = []; $totalChanges = 0; foreach ($files as $file) { if ($file->getExtension() === 'php' && str_ends_with($file->getFilename(), '.blade.php')) { $content = File::get($file->getPathname()); $originalContent = $content; foreach ($deprecatedLayouts as $deprecated) { $pattern = "/@extends\s*\(\s*['\"]" . preg_quote($deprecated, '/') . "['\"]\s*\)/"; if (preg_match($pattern, $content)) { $replacement = "@extends('{$activeLayout}')"; $content = preg_replace($pattern, $replacement, $content); if (!$dryRun) { File::put($file->getPathname(), $content); } $relativePath = str_replace(base_path() . '/', '', $file->getPathname()); $changedFiles[] = $relativePath; $totalChanges++; if ($dryRun) { $this->line("๐Ÿ”„ [DRY-RUN] {$relativePath}: {$deprecated} โ†’ {$activeLayout}"); } else { $this->line("โœ… {$relativePath}: {$deprecated} โ†’ {$activeLayout}"); } } } } } if ($totalChanges === 0) { $this->info("โœจ Nessun layout deprecato trovato. Tutto pulito!"); return; } if ($dryRun) { $this->warn("๐Ÿ“‹ [DRY-RUN] Sarebbero stati modificati {$totalChanges} file(s)."); $this->info("๐Ÿ’ก Rimuovi --dry-run per applicare le modifiche."); } else { $this->info("๐ŸŽ‰ Modificati {$totalChanges} file(s) con successo!"); // Pulisce le cache $this->info("๐Ÿงน Pulizia cache Laravel..."); $this->call('view:clear'); $this->call('config:clear'); $this->call('route:clear'); $this->info("โœ… Pulizia completata!"); } // Mostra riassunto if (!empty($changedFiles)) { $this->newLine(); $this->info("๐Ÿ“ File modificati:"); foreach ($changedFiles as $file) { $this->line(" โ€ข {$file}"); } } } }