98 lines
3.4 KiB
PHP
98 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class TestStampeRateModule extends Command
|
|
{
|
|
protected $signature = 'test:stampe-rate';
|
|
protected $description = 'Testa il modulo StampeRate senza autenticazione web';
|
|
|
|
public function handle()
|
|
{
|
|
$this->info('🧪 Test modulo StampeRate...');
|
|
|
|
try {
|
|
// Trova l'utente super-admin
|
|
$user = User::where('email', 'superadmin@example.com')->first();
|
|
|
|
if (!$user) {
|
|
$this->error('❌ Utente super-admin non trovato');
|
|
return Command::FAILURE;
|
|
}
|
|
|
|
$this->info("✅ Utente trovato: {$user->name} ({$user->email})");
|
|
$this->info("🔑 Ruoli: " . $user->roles->pluck('name')->implode(', '));
|
|
|
|
// Simula l'autenticazione
|
|
Auth::login($user);
|
|
$this->info('🔐 Autenticazione simulata');
|
|
|
|
// Test permessi
|
|
if ($user->can('stampe.rate.view')) {
|
|
$this->info('✅ Permesso stampe.rate.view: OK');
|
|
} else {
|
|
$this->error('❌ Permesso stampe.rate.view: MANCANTE');
|
|
}
|
|
|
|
// Test query stabili
|
|
$stabili = DB::table('stabili')
|
|
->where('amministratore_id', $user->id)
|
|
->select('id', 'denominazione', 'indirizzo')
|
|
->get();
|
|
|
|
$this->info("🏢 Stabili trovati: " . $stabili->count());
|
|
|
|
if ($stabili->count() === 0) {
|
|
$this->warn('⚠️ Nessuno stabile associato all\'utente');
|
|
$this->info('💡 Per testare completamente il modulo, aggiungere almeno uno stabile all\'utente nel database');
|
|
} else {
|
|
foreach ($stabili->take(3) as $stabile) {
|
|
$this->info(" - {$stabile->denominazione} ({$stabile->indirizzo})");
|
|
}
|
|
}
|
|
|
|
// Test query template
|
|
$templates = DB::table('stampe_rate_templates')
|
|
->where('status', 'active')
|
|
->select('id', 'name', 'description')
|
|
->get();
|
|
|
|
$this->info("📄 Template trovati: " . $templates->count());
|
|
|
|
foreach ($templates as $template) {
|
|
$this->info(" - {$template->name}: {$template->description}");
|
|
}
|
|
|
|
// Test view loading
|
|
$this->info('🎭 Test caricamento view...');
|
|
|
|
if (view()->exists('modules.stampe-rate.index')) {
|
|
$this->info('✅ View modules.stampe-rate.index: TROVATA');
|
|
} else {
|
|
$this->error('❌ View modules.stampe-rate.index: NON TROVATA');
|
|
|
|
// Controlla il symlink
|
|
$symlink = '/var/www/netgescon/resources/views/modules/stampe-rate';
|
|
if (is_link($symlink)) {
|
|
$this->info("🔗 Symlink presente: " . readlink($symlink));
|
|
} else {
|
|
$this->error("❌ Symlink mancante: {$symlink}");
|
|
}
|
|
}
|
|
|
|
$this->info('🎉 Test completato con successo!');
|
|
|
|
return Command::SUCCESS;
|
|
} catch (\Exception $e) {
|
|
$this->error("❌ Errore durante il test: " . $e->getMessage());
|
|
$this->error("📍 File: " . $e->getFile() . ":{$e->getLine()}");
|
|
return Command::FAILURE;
|
|
}
|
|
}
|
|
}
|