56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use Database\Seeders\DocumentiDemoSeeder;
|
|
|
|
class DocumentiDemoCommand extends Command
|
|
{
|
|
/**
|
|
* NETGESCON COMMAND: Documenti Demo
|
|
*
|
|
* Comando per creare dati demo persistenti per la gestione documentale.
|
|
*
|
|
* @author GitHub Copilot
|
|
* @date 21/07/2025
|
|
* @version 1.0.0
|
|
*/
|
|
protected $signature = 'netgescon:demo-documenti {--force : Forza la ricreazione anche se esistono già}';
|
|
protected $description = 'Crea documenti demo persistenti per la gestione documentale NetGescon';
|
|
|
|
public function handle()
|
|
{
|
|
$this->info('🚀 NetGescon - Creazione Documenti Demo Persistenti');
|
|
$this->info('================================================');
|
|
|
|
if ($this->option('force')) {
|
|
$this->warn('⚠️ Modalità FORCE attivata - ricreo tutti i documenti demo');
|
|
\DB::table('documenti')->where('is_demo', true)->delete();
|
|
\DB::table('etichette_protocollo')->truncate();
|
|
}
|
|
|
|
try {
|
|
$seeder = new DocumentiDemoSeeder();
|
|
$seeder->run();
|
|
|
|
$count = \DB::table('documenti')->where('is_demo', true)->count();
|
|
|
|
$this->info("✅ Operazione completata con successo!");
|
|
$this->info("📄 Documenti demo creati: {$count}");
|
|
$this->info("🔗 Accedi alla gestione documentale dal pannello NetGescon");
|
|
|
|
return Command::SUCCESS;
|
|
} catch (\Exception $e) {
|
|
$this->error("❌ Errore durante la creazione dei documenti demo:");
|
|
$this->error($e->getMessage());
|
|
|
|
if ($this->option('verbose')) {
|
|
$this->error($e->getTraceAsString());
|
|
}
|
|
|
|
return Command::FAILURE;
|
|
}
|
|
}
|
|
}
|