Stand: SMTP-Test, Admin-Mail-Tab, Notifiable-Fix, Lazy-Quill
- 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>
This commit is contained in:
44
app/Http/Middleware/SetLocaleMiddleware.php
Executable file
44
app/Http/Middleware/SetLocaleMiddleware.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class SetLocaleMiddleware
|
||||
{
|
||||
private const SUPPORTED_LOCALES = ['de', 'en', 'pl', 'ru', 'ar', 'tr'];
|
||||
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$locale = $this->resolveLocale($request);
|
||||
|
||||
app()->setLocale($locale);
|
||||
Carbon::setLocale($locale);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
private function resolveLocale(Request $request): string
|
||||
{
|
||||
// 1. Eingeloggter User → DB-Präferenz
|
||||
if ($request->user() && in_array($request->user()->locale, self::SUPPORTED_LOCALES)) {
|
||||
return $request->user()->locale;
|
||||
}
|
||||
|
||||
// 2. Session (für Gastseiten)
|
||||
if (session()->has('locale') && in_array(session('locale'), self::SUPPORTED_LOCALES)) {
|
||||
return session('locale');
|
||||
}
|
||||
|
||||
// 3. Fallback
|
||||
return 'de';
|
||||
}
|
||||
|
||||
public static function supportedLocales(): array
|
||||
{
|
||||
return self::SUPPORTED_LOCALES;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user