- Fix: Notifiable-Trait zum User-Model hinzugefuegt (behebt notify()-500er) - Installer: SMTP-Verbindungstest mit EsmtpTransport + Ueberspringen-Link - Admin: Neuer E-Mail-Tab mit SMTP-Konfiguration + Verbindungstest - Admin: Lazy Quill-Initialisierung (nur sichtbare Locale wird geladen) - Uebersetzungen: 17 neue Mail-Keys in allen 6 Sprachen Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
127 lines
3.8 KiB
PHP
127 lines
3.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\Setting;
|
|
use App\Services\SupportApiService;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\View\View;
|
|
|
|
class SupportController extends Controller
|
|
{
|
|
public function __construct(private SupportApiService $supportService) {}
|
|
|
|
/**
|
|
* Nur Admins duerfen den Support-Bereich nutzen (T05).
|
|
*/
|
|
private function authorizeAdmin(): void
|
|
{
|
|
if (!auth()->user()->isAdmin()) {
|
|
abort(403);
|
|
}
|
|
}
|
|
|
|
public function index(): View
|
|
{
|
|
$this->authorizeAdmin();
|
|
$registered = $this->supportService->isRegistered();
|
|
$tickets = $registered ? ($this->supportService->getTickets() ?? []) : [];
|
|
|
|
return view('admin.support.index', compact('registered', 'tickets'));
|
|
}
|
|
|
|
public function show(int $ticketId): View|RedirectResponse
|
|
{
|
|
$this->authorizeAdmin();
|
|
|
|
if (!$this->supportService->isRegistered()) {
|
|
return redirect()->route('admin.support.index');
|
|
}
|
|
|
|
$ticket = $this->supportService->getTicket($ticketId);
|
|
if (!$ticket) {
|
|
return redirect()->route('admin.support.index')
|
|
->with('error', __('admin.support_ticket_not_found'));
|
|
}
|
|
|
|
return view('admin.support.show', compact('ticket'));
|
|
}
|
|
|
|
public function store(Request $request): RedirectResponse
|
|
{
|
|
$this->authorizeAdmin();
|
|
|
|
$request->validate([
|
|
'subject' => 'required|string|max:255',
|
|
'message' => 'required|string|max:5000',
|
|
'category' => 'required|string|in:bug,feature,question,other',
|
|
]);
|
|
|
|
$result = $this->supportService->createTicket([
|
|
'subject' => $request->input('subject'),
|
|
'message' => $request->input('message'),
|
|
'category' => $request->input('category'),
|
|
'system_info' => $this->supportService->getSystemInfo(),
|
|
'license_key' => Setting::get('license_key'),
|
|
]);
|
|
|
|
if (!$result) {
|
|
return back()->withInput()
|
|
->with('error', __('admin.support_submit_failed'));
|
|
}
|
|
|
|
return redirect()->route('admin.support.show', $result['ticket_id'] ?? 0)
|
|
->with('success', __('admin.support_ticket_created'));
|
|
}
|
|
|
|
public function reply(Request $request, int $ticketId): RedirectResponse
|
|
{
|
|
$this->authorizeAdmin();
|
|
|
|
$request->validate([
|
|
'message' => 'required|string|max:5000',
|
|
]);
|
|
|
|
$result = $this->supportService->replyToTicket($ticketId, [
|
|
'message' => $request->input('message'),
|
|
]);
|
|
|
|
if (!$result) {
|
|
return back()->withInput()
|
|
->with('error', __('admin.support_reply_failed'));
|
|
}
|
|
|
|
return redirect()->route('admin.support.show', $ticketId)
|
|
->with('success', __('admin.support_reply_sent'));
|
|
}
|
|
|
|
public function register(): RedirectResponse
|
|
{
|
|
$this->authorizeAdmin();
|
|
|
|
$data = [
|
|
'app_name' => Setting::get('app_name', config('app.name')),
|
|
'app_url' => config('app.url'),
|
|
'app_version' => config('app.version'),
|
|
'php_version' => PHP_VERSION,
|
|
'db_driver' => config('database.default'),
|
|
'installed_at' => $this->supportService->readInstalled()['installed_at'] ?? now()->toIso8601String(),
|
|
];
|
|
|
|
$logoUrl = $this->supportService->getLogoUrl();
|
|
if ($logoUrl) {
|
|
$data['logo_url'] = $logoUrl;
|
|
}
|
|
|
|
$result = $this->supportService->register($data);
|
|
|
|
if ($result) {
|
|
return back()->with('success', __('admin.registration_success'));
|
|
}
|
|
|
|
return back()->with('error', __('admin.registration_failed'));
|
|
}
|
|
}
|