LMIV-SNACKAUTOMAT/app/Console/Commands/TestTenantSettings.php

74 lines
2.1 KiB
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\Tenant;
class TestTenantSettings extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'test:tenant-settings';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Test tenant settings functionality';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('=== Mandanten-Einstellungen Test ===');
$tenant = Tenant::first();
if (!$tenant) {
$this->error('Kein Mandant gefunden!');
return 1;
}
$this->info("Tenant ID: {$tenant->id}");
$this->info("Tenant Name: {$tenant->name}");
$this->info("show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
$this->info("show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
$this->newLine();
// Test: Einstellungen ändern
$this->info('=== Test: Einstellungen ändern ===');
$originalPrices = $tenant->show_prices;
$originalStock = $tenant->show_stock;
// Ändere Einstellungen
$tenant->show_prices = false;
$tenant->show_stock = false;
$tenant->save();
// Lade neu und prüfe
$tenant->refresh();
$this->info("Nach Änderung - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
$this->info("Nach Änderung - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
// Zurücksetzen
$tenant->show_prices = $originalPrices;
$tenant->show_stock = $originalStock;
$tenant->save();
$tenant->refresh();
$this->info("Zurückgesetzt - show_prices: " . ($tenant->show_prices ? 'true' : 'false'));
$this->info("Zurückgesetzt - show_stock: " . ($tenant->show_stock ? 'true' : 'false'));
$this->newLine();
$this->info('✅ Test erfolgreich!');
return 0;
}
}