Backend-WIP: Kontakt-Queue, Page-Cache, Validierungs-Feedback, i18n

Gebuendelt, da ueber gemeinsame lang-/Service-Dateien verschraenkt:
- Kontakt-Nachrichten: contact_messages-Tabelle + Model/Enums/Factory,
  Admin-Queue (livewire/admin/contact-messages), ContactController
  persistiert das Anliegen zusaetzlich zur Brand-Mail
- Page-Data-Cache (Services/Web/*PageData) + web-archive-Indizes auf
  press_releases
- Validierungs-Feedback + Company-Portal-Restriction (Feature-Tests)
- i18n-Auslagerung lang/de|en (auth, passwords, validation, static)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin Adametz 2026-07-09 15:38:11 +00:00
parent c6b5ec8479
commit fd8e050cb7
60 changed files with 3963 additions and 327 deletions

View file

@ -0,0 +1,45 @@
<?php
namespace Database\Factories;
use App\Enums\ContactMessageStatus;
use App\Enums\ContactMessageTopic;
use App\Models\ContactMessage;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<ContactMessage>
*/
class ContactMessageFactory extends Factory
{
/**
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'portal' => 'presseecho',
'topic' => fake()->randomElement(ContactMessageTopic::cases()),
'status' => ContactMessageStatus::Open,
'name' => fake()->name(),
'email' => fake()->safeEmail(),
'message' => fake()->sentence(12),
'page_url' => fake()->url(),
'payload' => null,
'requester_ip' => fake()->ipv4(),
];
}
public function topic(ContactMessageTopic $topic): static
{
return $this->state(['topic' => $topic]);
}
public function resolved(): static
{
return $this->state([
'status' => ContactMessageStatus::Resolved,
'resolved_at' => now(),
]);
}
}

View file

@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Kontakt-Anliegen aus dem schwebenden Kontakt-Widget und dem Hub-Kontakt-
* Modal: Kontaktaufnahme, Fehlermeldung, PM-Meldung und Feedback laufen in
* eine gemeinsame Admin-Queue („Kontakt"). Bewusst getrennt von den
* Compliance-Anfragen (legal_requests).
*/
return new class extends Migration
{
public function up(): void
{
Schema::create('contact_messages', function (Blueprint $table) {
$table->id();
$table->string('portal', 40)->nullable();
$table->string('topic', 40)->default('contact');
$table->string('status', 40)->default('open');
$table->string('name')->nullable();
$table->string('email')->nullable();
$table->text('message')->nullable();
// Seite, von der das Widget abgeschickt wurde (Kontext für Fehler-/PM-Meldungen).
$table->string('page_url', 500)->nullable();
$table->json('payload')->nullable();
$table->string('requester_ip', 45)->nullable();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('resolved_by_user_id')->nullable()->constrained('users')->nullOnDelete();
$table->text('admin_note')->nullable();
$table->timestamp('resolved_at')->nullable();
$table->timestamps();
$table->index(['status', 'topic']);
});
}
public function down(): void
{
Schema::dropIfExists('contact_messages');
}
};

View file

@ -0,0 +1,53 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Composite-Indizes für die öffentlichen Web-Seiten (Start-/Kategorieseite,
* Ticker, EditorialClock): Alle Archiv-Abfragen filtern nach
* portal + language + status (+ SoftDelete) und sortieren/aggregieren über
* published_at. deleted_at gehört mit in den Index: Erst dadurch sind
* MAX()/COUNT()-Abfragen index-covering und der MySQL-Optimizer wählt den
* Index von selbst (gemessen: MAX(published_at) von ~900 ms auf ~4 ms).
*/
return new class extends Migration
{
public function up(): void
{
Schema::table('press_releases', function (Blueprint $table): void {
if (! $this->hasIndex('press_releases', 'press_releases_web_archive_idx')) {
$table->index(
['portal', 'language', 'status', 'deleted_at', 'published_at'],
'press_releases_web_archive_idx'
);
}
if (! $this->hasIndex('press_releases', 'press_releases_category_web_archive_idx')) {
$table->index(
['category_id', 'language', 'status', 'deleted_at', 'published_at'],
'press_releases_category_web_archive_idx'
);
}
});
}
public function down(): void
{
Schema::table('press_releases', function (Blueprint $table): void {
if ($this->hasIndex('press_releases', 'press_releases_category_web_archive_idx')) {
$table->dropIndex('press_releases_category_web_archive_idx');
}
if ($this->hasIndex('press_releases', 'press_releases_web_archive_idx')) {
$table->dropIndex('press_releases_web_archive_idx');
}
});
}
private function hasIndex(string $table, string $indexName): bool
{
return in_array($indexName, array_column(Schema::getIndexes($table), 'name'), true);
}
};