63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Tenant;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\View\View;
|
|
|
|
class DebugSettingsController extends Controller
|
|
{
|
|
public function updateTenantSettings(Request $request): RedirectResponse
|
|
{
|
|
// Logging für Debug
|
|
\Log::info('=== DEBUG SETTINGS CONTROLLER ERREICHT ===', [
|
|
'method' => $request->method(),
|
|
'all_data' => $request->all(),
|
|
'has_show_prices' => $request->has('show_prices'),
|
|
'has_show_stock' => $request->has('show_stock'),
|
|
'user_id' => auth()->id(),
|
|
'session_tenant_id' => session('current_tenant_id')
|
|
]);
|
|
|
|
// Nimm einfach den ersten Mandanten
|
|
$tenant = Tenant::first();
|
|
|
|
if (!$tenant) {
|
|
\Log::error('Kein Mandant gefunden!');
|
|
return redirect()->back()->with('error', 'Kein Mandant gefunden');
|
|
}
|
|
|
|
// Alte Werte loggen
|
|
$oldValues = [
|
|
'show_prices' => $tenant->show_prices,
|
|
'show_stock' => $tenant->show_stock
|
|
];
|
|
|
|
\Log::info('Alte Werte:', $oldValues);
|
|
|
|
// Neue Werte setzen
|
|
$newValues = [
|
|
'show_prices' => $request->has('show_prices'),
|
|
'show_stock' => $request->has('show_stock')
|
|
];
|
|
|
|
\Log::info('Neue Werte:', $newValues);
|
|
|
|
// Update durchführen
|
|
$tenant->update($newValues);
|
|
|
|
// Prüfen ob Update erfolgreich
|
|
$tenant->refresh();
|
|
$finalValues = [
|
|
'show_prices' => $tenant->show_prices,
|
|
'show_stock' => $tenant->show_stock
|
|
];
|
|
|
|
\Log::info('Final Werte nach Update:', $finalValues);
|
|
|
|
return redirect()->route('admin.settings.tenant')
|
|
->with('success', 'DEBUG: Einstellungen gespeichert - siehe Log für Details');
|
|
}
|
|
} |