Recht: Kuendigungsbutton nach Par. 312k BGB - Backend + Admin-Queue
Oeffentliche Bestaetigungsseite /de/kuendigung ohne Login: Art der Kuendigung (Grund nur bei ausserordentlich), Zuordnungsdaten, Beendigungszeitpunkt; Honeypot + Rate-Limit wie beim Widerruf. Sofortige automatische Zugangsbestaetigung per E-Mail (Par. 312k Abs. 4 BGB) + Betreiber-Mail. Kuendigungen laufen in der Recht-&-Compliance-Queue unter den Widerrufen auf (K-Vorgaenge, eigener Filter, Erledigt/Wieder-oeffnen, vierte KPI-Karte). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
981be2f2ee
commit
8b8f2991c6
12 changed files with 826 additions and 2 deletions
115
app/Http/Controllers/Web/TerminationController.php
Normal file
115
app/Http/Controllers/Web/TerminationController.php
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Web;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Mail\TerminationRequestReceived;
|
||||||
|
use App\Mail\TerminationRequestSubmitted;
|
||||||
|
use App\Models\TerminationRequest;
|
||||||
|
use App\Support\WebPortalContext;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gesetzlicher Kündigungsbutton (§ 312k BGB): Verbraucher können laufende
|
||||||
|
* Verträge (Abos) ohne Login über eine öffentlich erreichbare
|
||||||
|
* Bestätigungsseite kündigen. Erfasst werden Art der Kündigung (Grund nur
|
||||||
|
* bei außerordentlicher Kündigung), Zuordnungsdaten und der gewünschte
|
||||||
|
* Beendigungszeitpunkt. Der Zugang der Erklärung wird sofort automatisch
|
||||||
|
* per E-Mail bestätigt (Inhalt, Datum und Uhrzeit des Zugangs).
|
||||||
|
*/
|
||||||
|
class TerminationController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bestätigungsseite mit dem Kündigungsformular (§ 312k Abs. 2 BGB).
|
||||||
|
*/
|
||||||
|
public function show(): View
|
||||||
|
{
|
||||||
|
return view('web.kuendigung');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request): RedirectResponse
|
||||||
|
{
|
||||||
|
// Bot: ein ausgefülltes Honeypot-Feld → still und neutral abnicken,
|
||||||
|
// bewusst VOR der Validierung (sonst verrät die Regel die Falle).
|
||||||
|
if (filled($request->input('website')) || filled($request->input('homepage'))) {
|
||||||
|
return $this->done();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Eigener Error-Bag, damit sich das Kontakt-Modal im Hub-Footer
|
||||||
|
// (öffnet auf Default-Bag-Fehler) nicht mit öffnet.
|
||||||
|
$validated = $request->validateWithBag('termination', [
|
||||||
|
'kind' => ['required', 'in:ordentlich,ausserordentlich'],
|
||||||
|
'reason' => ['required_if:kind,ausserordentlich', 'nullable', 'string', 'max:2000'],
|
||||||
|
'name' => ['required', 'string', 'max:255'],
|
||||||
|
'email' => ['required', 'email', 'max:255'],
|
||||||
|
'contract_reference' => ['nullable', 'string', 'max:255'],
|
||||||
|
'terminate_mode' => ['required', 'in:asap,date'],
|
||||||
|
'terminate_at' => ['required_if:terminate_mode,date', 'nullable', 'date'],
|
||||||
|
], [
|
||||||
|
'reason.required_if' => __('Bitte geben Sie den Grund der außerordentlichen Kündigung an.'),
|
||||||
|
'terminate_at.required_if' => __('Bitte geben Sie das gewünschte Beendigungsdatum an.'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->ensureNotRateLimited($request);
|
||||||
|
RateLimiter::hit($this->throttleKey($request), 3600);
|
||||||
|
|
||||||
|
$terminationRequest = TerminationRequest::query()->create([
|
||||||
|
'kind' => $validated['kind'],
|
||||||
|
'reason' => $validated['kind'] === 'ausserordentlich' ? ($validated['reason'] ?? null) : null,
|
||||||
|
'name' => $validated['name'],
|
||||||
|
'email' => $validated['email'],
|
||||||
|
'contract_reference' => $validated['contract_reference'] ?? null,
|
||||||
|
'terminate_at' => $validated['terminate_mode'] === 'date' ? $validated['terminate_at'] : null,
|
||||||
|
'host' => $request->getHost(),
|
||||||
|
'requester_ip' => $request->ip(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// § 312k Abs. 4 BGB: Zugang der Kündigungserklärung sofort auf
|
||||||
|
// elektronischem Wege bestätigen (Inhalt, Datum, Uhrzeit).
|
||||||
|
Mail::to($terminationRequest->email)->send(new TerminationRequestReceived($terminationRequest));
|
||||||
|
Mail::to($this->operatorRecipient())->send(new TerminationRequestSubmitted($terminationRequest));
|
||||||
|
|
||||||
|
return $this->done();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function done(): RedirectResponse
|
||||||
|
{
|
||||||
|
return back()->with('termination-status', __('Ihre Kündigung ist bei uns eingegangen. Sie erhalten umgehend eine automatische Eingangsbestätigung per E-Mail mit Datum und Uhrzeit des Zugangs.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function operatorRecipient(): string
|
||||||
|
{
|
||||||
|
if (str_contains(request()->getHost(), 'pressekonto')) {
|
||||||
|
$brand = config('domains.domains.pressekonto.brand', []);
|
||||||
|
} else {
|
||||||
|
$brand = WebPortalContext::fromRequest()->domainConfig['brand'] ?? [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $brand['contact_email'] ?? config('mail.from.address');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function ensureNotRateLimited(Request $request): void
|
||||||
|
{
|
||||||
|
if (! RateLimiter::tooManyAttempts($this->throttleKey($request), 5)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$seconds = RateLimiter::availableIn($this->throttleKey($request));
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => __('Zu viele Anfragen. Bitte versuchen Sie es in :minutes Minuten erneut.', [
|
||||||
|
'minutes' => max(1, (int) ceil($seconds / 60)),
|
||||||
|
]),
|
||||||
|
])->errorBag('termination');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function throttleKey(Request $request): string
|
||||||
|
{
|
||||||
|
return 'termination-form|'.$request->ip();
|
||||||
|
}
|
||||||
|
}
|
||||||
36
app/Mail/TerminationRequestReceived.php
Normal file
36
app/Mail/TerminationRequestReceived.php
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Models\TerminationRequest;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sofortige automatische Zugangsbestätigung an den Verbraucher — gesetzlich
|
||||||
|
* vorgeschrieben beim Kündigungsbutton (§ 312k Abs. 4 BGB): Inhalt sowie
|
||||||
|
* Datum und Uhrzeit des Zugangs der Kündigungserklärung.
|
||||||
|
*/
|
||||||
|
class TerminationRequestReceived extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public readonly TerminationRequest $terminationRequest,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Eingangsbestätigung: Ihre Kündigung vom '.$this->terminationRequest->created_at->format('d.m.Y'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
return new Content(view: 'emails.termination.received');
|
||||||
|
}
|
||||||
|
}
|
||||||
35
app/Mail/TerminationRequestSubmitted.php
Normal file
35
app/Mail/TerminationRequestSubmitted.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use App\Models\TerminationRequest;
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interne Benachrichtigung an den Betreiber über eine neue Online-Kündigung
|
||||||
|
* (Kündigungsbutton § 312k BGB) — Bearbeitung über die Admin-Queue.
|
||||||
|
*/
|
||||||
|
class TerminationRequestSubmitted extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
public readonly TerminationRequest $terminationRequest,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Neue Online-Kündigung (K-'.$this->terminationRequest->id.'): '.$this->terminationRequest->name,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
return new Content(view: 'emails.termination.submitted');
|
||||||
|
}
|
||||||
|
}
|
||||||
60
app/Models/TerminationRequest.php
Normal file
60
app/Models/TerminationRequest.php
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Database\Factories\TerminationRequestFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Online-Kündigung über den gesetzlichen Kündigungsbutton (§ 312k BGB, ohne
|
||||||
|
* Login). `kind` = ordentlich|ausserordentlich (Grund nur bei außerordentlich),
|
||||||
|
* `terminate_at` NULL = zum nächstmöglichen Zeitpunkt.
|
||||||
|
*/
|
||||||
|
class TerminationRequest extends Model
|
||||||
|
{
|
||||||
|
/** @use HasFactory<TerminationRequestFactory> */
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'kind',
|
||||||
|
'reason',
|
||||||
|
'name',
|
||||||
|
'email',
|
||||||
|
'contract_reference',
|
||||||
|
'terminate_at',
|
||||||
|
'host',
|
||||||
|
'requester_ip',
|
||||||
|
'status',
|
||||||
|
'resolved_at',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected function casts(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'terminate_at' => 'date',
|
||||||
|
'resolved_at' => 'datetime',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function scopeOpen(Builder $query): Builder
|
||||||
|
{
|
||||||
|
return $query->where('status', 'open');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isExtraordinary(): bool
|
||||||
|
{
|
||||||
|
return $this->kind === 'ausserordentlich';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function kindLabel(): string
|
||||||
|
{
|
||||||
|
return $this->isExtraordinary() ? 'Außerordentliche Kündigung' : 'Ordentliche Kündigung';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function terminateAtLabel(): string
|
||||||
|
{
|
||||||
|
return $this->terminate_at?->format('d.m.Y') ?? 'zum nächstmöglichen Zeitpunkt';
|
||||||
|
}
|
||||||
|
}
|
||||||
47
database/factories/TerminationRequestFactory.php
Normal file
47
database/factories/TerminationRequestFactory.php
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\TerminationRequest;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Factory<TerminationRequest>
|
||||||
|
*/
|
||||||
|
class TerminationRequestFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'kind' => 'ordentlich',
|
||||||
|
'reason' => null,
|
||||||
|
'name' => fake()->name(),
|
||||||
|
'email' => fake()->safeEmail(),
|
||||||
|
'contract_reference' => null,
|
||||||
|
'terminate_at' => null,
|
||||||
|
'host' => 'pressekonto.test',
|
||||||
|
'requester_ip' => fake()->ipv4(),
|
||||||
|
'status' => 'open',
|
||||||
|
'resolved_at' => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function extraordinary(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn (): array => [
|
||||||
|
'kind' => 'ausserordentlich',
|
||||||
|
'reason' => fake()->sentence(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolved(): static
|
||||||
|
{
|
||||||
|
return $this->state(fn (): array => [
|
||||||
|
'status' => 'resolved',
|
||||||
|
'resolved_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Online-Kündigung über den gesetzlichen Kündigungsbutton (§ 312k BGB):
|
||||||
|
* Verbraucher können Dauerschuldverhältnisse (Abos) ohne Login kündigen.
|
||||||
|
* Die Bestätigungsseite erfasst Art der Kündigung (ordentlich/außerordentlich,
|
||||||
|
* bei außerordentlich mit Grund), Zuordnungsdaten und den gewünschten
|
||||||
|
* Beendigungszeitpunkt. Der Eingang wird sofort automatisch per E-Mail
|
||||||
|
* bestätigt (inkl. Datum/Uhrzeit des Zugangs); die Bearbeitung erfolgt manuell.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('termination_requests', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
|
||||||
|
$table->string('kind', 40)->default('ordentlich');
|
||||||
|
$table->text('reason')->nullable();
|
||||||
|
|
||||||
|
$table->string('name');
|
||||||
|
$table->string('email');
|
||||||
|
$table->string('contract_reference')->nullable();
|
||||||
|
|
||||||
|
$table->date('terminate_at')->nullable();
|
||||||
|
|
||||||
|
$table->string('host')->nullable();
|
||||||
|
$table->string('requester_ip', 45)->nullable();
|
||||||
|
|
||||||
|
$table->string('status', 40)->default('open');
|
||||||
|
$table->timestamp('resolved_at')->nullable();
|
||||||
|
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index(['status', 'created_at']);
|
||||||
|
$table->index('email');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('termination_requests');
|
||||||
|
}
|
||||||
|
};
|
||||||
55
resources/views/emails/termination/received.blade.php
Normal file
55
resources/views/emails/termination/received.blade.php
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Eingangsbestätigung Ihrer Kündigung</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px; }
|
||||||
|
.meta { background: #f8fafc; border-left: 4px solid #2563eb; padding: 12px 16px; margin: 16px 0; }
|
||||||
|
.meta dt { font-weight: bold; color: #111; }
|
||||||
|
.meta dd { margin: 0 0 8px; }
|
||||||
|
.note { font-size: 13px; color: #666; border-top: 1px solid #eee; padding-top: 12px; margin-top: 24px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>Guten Tag {{ $terminationRequest->name }},</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
hiermit bestätigen wir den Eingang Ihrer Kündigungserklärung. Ihre Erklärung ist bei uns
|
||||||
|
am <strong>{{ $terminationRequest->created_at->format('d.m.Y') }}
|
||||||
|
um {{ $terminationRequest->created_at->format('H:i') }} Uhr</strong> eingegangen.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<dl class="meta">
|
||||||
|
<dt>Art der Kündigung</dt>
|
||||||
|
<dd>{{ $terminationRequest->kindLabel() }}</dd>
|
||||||
|
@if ($terminationRequest->isExtraordinary() && $terminationRequest->reason)
|
||||||
|
<dt>Kündigungsgrund</dt>
|
||||||
|
<dd>{{ $terminationRequest->reason }}</dd>
|
||||||
|
@endif
|
||||||
|
<dt>Name</dt>
|
||||||
|
<dd>{{ $terminationRequest->name }}</dd>
|
||||||
|
<dt>E-Mail</dt>
|
||||||
|
<dd>{{ $terminationRequest->email }}</dd>
|
||||||
|
@if ($terminationRequest->contract_reference)
|
||||||
|
<dt>Vertrags-/Rechnungsnummer</dt>
|
||||||
|
<dd>{{ $terminationRequest->contract_reference }}</dd>
|
||||||
|
@endif
|
||||||
|
<dt>Gewünschte Beendigung</dt>
|
||||||
|
<dd>{{ $terminationRequest->terminateAtLabel() }}</dd>
|
||||||
|
<dt>Vorgangsnummer</dt>
|
||||||
|
<dd>K-{{ $terminationRequest->id }}</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Wir ordnen Ihre Kündigung dem zugehörigen Vertrag zu und bestätigen Ihnen
|
||||||
|
schnellstmöglich den Zeitpunkt, zu dem das Vertragsverhältnis endet.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p class="note">
|
||||||
|
Diese Bestätigung wurde automatisch erstellt und dokumentiert Inhalt sowie Datum
|
||||||
|
und Uhrzeit des Zugangs Ihrer Kündigungserklärung (§ 312k BGB).
|
||||||
|
Bitte bewahren Sie sie auf.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
43
resources/views/emails/termination/submitted.blade.php
Normal file
43
resources/views/emails/termination/submitted.blade.php
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Neue Online-Kündigung</title>
|
||||||
|
<style>
|
||||||
|
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 600px; margin: 0 auto; padding: 20px; }
|
||||||
|
.meta { background: #fef2f2; border-left: 4px solid #dc2626; padding: 12px 16px; margin: 16px 0; }
|
||||||
|
.meta dt { font-weight: bold; color: #111; }
|
||||||
|
.meta dd { margin: 0 0 8px; }
|
||||||
|
.note { font-size: 13px; color: #666; border-top: 1px solid #eee; padding-top: 12px; margin-top: 24px; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<p>Über den Kündigungsbutton auf <strong>{{ $terminationRequest->host }}</strong> ist eine neue Kündigung eingegangen:</p>
|
||||||
|
|
||||||
|
<dl class="meta">
|
||||||
|
<dt>Vorgangsnummer</dt>
|
||||||
|
<dd>K-{{ $terminationRequest->id }}</dd>
|
||||||
|
<dt>Art der Kündigung</dt>
|
||||||
|
<dd>{{ $terminationRequest->kindLabel() }}</dd>
|
||||||
|
@if ($terminationRequest->isExtraordinary())
|
||||||
|
<dt>Kündigungsgrund</dt>
|
||||||
|
<dd>{{ $terminationRequest->reason ?: '— nicht angegeben —' }}</dd>
|
||||||
|
@endif
|
||||||
|
<dt>Name</dt>
|
||||||
|
<dd>{{ $terminationRequest->name }}</dd>
|
||||||
|
<dt>E-Mail</dt>
|
||||||
|
<dd><a href="mailto:{{ $terminationRequest->email }}">{{ $terminationRequest->email }}</a></dd>
|
||||||
|
<dt>Vertrags-/Rechnungsnummer</dt>
|
||||||
|
<dd>{{ $terminationRequest->contract_reference ?: '— nicht angegeben —' }}</dd>
|
||||||
|
<dt>Gewünschte Beendigung</dt>
|
||||||
|
<dd>{{ $terminationRequest->terminateAtLabel() }}</dd>
|
||||||
|
<dt>Eingegangen</dt>
|
||||||
|
<dd>{{ $terminationRequest->created_at->format('d.m.Y H:i') }} Uhr</dd>
|
||||||
|
</dl>
|
||||||
|
|
||||||
|
<p class="note">
|
||||||
|
Die Zugangsbestätigung an den Verbraucher wurde automatisch versendet (§ 312k Abs. 4 BGB).
|
||||||
|
Bitte den Vorgang dem Vertrag zuordnen und dem Kunden den Beendigungszeitpunkt bestätigen.
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
use App\Enums\LegalRequestStatus;
|
use App\Enums\LegalRequestStatus;
|
||||||
use App\Enums\LegalRequestType;
|
use App\Enums\LegalRequestType;
|
||||||
use App\Models\LegalRequest;
|
use App\Models\LegalRequest;
|
||||||
|
use App\Models\TerminationRequest;
|
||||||
use App\Models\WithdrawalRequest;
|
use App\Models\WithdrawalRequest;
|
||||||
use Livewire\Attributes\Layout;
|
use Livewire\Attributes\Layout;
|
||||||
use Livewire\Attributes\Title;
|
use Livewire\Attributes\Title;
|
||||||
|
|
@ -23,6 +24,9 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
#[Url(as: 'widerrufe', except: 'open')]
|
#[Url(as: 'widerrufe', except: 'open')]
|
||||||
public string $withdrawalStatusFilter = 'open';
|
public string $withdrawalStatusFilter = 'open';
|
||||||
|
|
||||||
|
#[Url(as: 'kuendigungen', except: 'open')]
|
||||||
|
public string $terminationStatusFilter = 'open';
|
||||||
|
|
||||||
public function updatedStatusFilter(): void
|
public function updatedStatusFilter(): void
|
||||||
{
|
{
|
||||||
$this->resetPage();
|
$this->resetPage();
|
||||||
|
|
@ -38,6 +42,11 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
$this->resetPage('withdrawals');
|
$this->resetPage('withdrawals');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updatedTerminationStatusFilter(): void
|
||||||
|
{
|
||||||
|
$this->resetPage('terminations');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widerruf als erledigt markieren (Rückabwicklung angestoßen/abgeschlossen).
|
* Widerruf als erledigt markieren (Rückabwicklung angestoßen/abgeschlossen).
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,6 +66,26 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kündigung (§ 312k) als erledigt markieren (Vertrag beendet, Kunde hat
|
||||||
|
* die Bestätigung des Beendigungszeitpunkts erhalten).
|
||||||
|
*/
|
||||||
|
public function resolveTermination(int $id): void
|
||||||
|
{
|
||||||
|
TerminationRequest::query()->findOrFail($id)->update([
|
||||||
|
'status' => 'resolved',
|
||||||
|
'resolved_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reopenTermination(int $id): void
|
||||||
|
{
|
||||||
|
TerminationRequest::query()->findOrFail($id)->update([
|
||||||
|
'status' => 'open',
|
||||||
|
'resolved_at' => null,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
public function with(): array
|
public function with(): array
|
||||||
{
|
{
|
||||||
$requests = LegalRequest::query()
|
$requests = LegalRequest::query()
|
||||||
|
|
@ -73,6 +102,12 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
->latest()
|
->latest()
|
||||||
->paginate(25, pageName: 'withdrawals');
|
->paginate(25, pageName: 'withdrawals');
|
||||||
|
|
||||||
|
$terminations = TerminationRequest::query()
|
||||||
|
->when($this->terminationStatusFilter === 'open', fn ($query) => $query->open())
|
||||||
|
->when($this->terminationStatusFilter === 'resolved', fn ($query) => $query->where('status', 'resolved'))
|
||||||
|
->latest()
|
||||||
|
->paginate(25, pageName: 'terminations');
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'requests' => $requests,
|
'requests' => $requests,
|
||||||
'typeOptions' => LegalRequestType::cases(),
|
'typeOptions' => LegalRequestType::cases(),
|
||||||
|
|
@ -80,6 +115,8 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
'totalCount' => LegalRequest::query()->count(),
|
'totalCount' => LegalRequest::query()->count(),
|
||||||
'withdrawals' => $withdrawals,
|
'withdrawals' => $withdrawals,
|
||||||
'openWithdrawalCount' => WithdrawalRequest::query()->open()->count(),
|
'openWithdrawalCount' => WithdrawalRequest::query()->open()->count(),
|
||||||
|
'terminations' => $terminations,
|
||||||
|
'openTerminationCount' => TerminationRequest::query()->open()->count(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -100,11 +137,11 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
:badge="__('Admin Backend')"
|
:badge="__('Admin Backend')"
|
||||||
:eyebrow="__('Administration · Recht & Compliance')"
|
:eyebrow="__('Administration · Recht & Compliance')"
|
||||||
:title="__('Recht & Compliance')"
|
:title="__('Recht & Compliance')"
|
||||||
:description="__('DSGVO-Anonymisierung, Persönlichkeitsrechte und Meldungen zu Pressemitteilungen sowie Online-Widerrufe über den Widerrufsbutton – manuelle Bearbeitung, keine KI.')"
|
:description="__('DSGVO-Anonymisierung, Persönlichkeitsrechte und Meldungen zu Pressemitteilungen sowie Online-Widerrufe (Widerrufsbutton) und Online-Kündigungen (Kündigungsbutton § 312k BGB) – manuelle Bearbeitung, keine KI.')"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{{-- ============== KPI-Reihe ============== --}}
|
{{-- ============== KPI-Reihe ============== --}}
|
||||||
<section class="grid grid-cols-1 gap-4 sm:grid-cols-3">
|
<section class="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4">
|
||||||
<x-portal.stat-card variant="primary" :label="__('Offen')" :value="number_format($openCount)">
|
<x-portal.stat-card variant="primary" :label="__('Offen')" :value="number_format($openCount)">
|
||||||
<x-slot:meta>{{ __('zu bearbeiten') }}</x-slot:meta>
|
<x-slot:meta>{{ __('zu bearbeiten') }}</x-slot:meta>
|
||||||
<x-slot:trend>{{ __('offen + in Bearbeitung') }}</x-slot:trend>
|
<x-slot:trend>{{ __('offen + in Bearbeitung') }}</x-slot:trend>
|
||||||
|
|
@ -117,6 +154,10 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
<x-slot:meta>{{ __('Online-Widerruf') }}</x-slot:meta>
|
<x-slot:meta>{{ __('Online-Widerruf') }}</x-slot:meta>
|
||||||
<x-slot:trend>{{ __('gesetzliche Frist beachten') }}</x-slot:trend>
|
<x-slot:trend>{{ __('gesetzliche Frist beachten') }}</x-slot:trend>
|
||||||
</x-portal.stat-card>
|
</x-portal.stat-card>
|
||||||
|
<x-portal.stat-card variant="warn" :label="__('Offene Kündigungen')" :value="number_format($openTerminationCount)">
|
||||||
|
<x-slot:meta>{{ __('Kündigungsbutton § 312k') }}</x-slot:meta>
|
||||||
|
<x-slot:trend>{{ __('Beendigungszeitpunkt bestätigen') }}</x-slot:trend>
|
||||||
|
</x-portal.stat-card>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{{-- ============== FILTER ============== --}}
|
{{-- ============== FILTER ============== --}}
|
||||||
|
|
@ -314,4 +355,120 @@ new #[Layout('components.layouts.app'), Title('Recht & Compliance')] class exten
|
||||||
|
|
||||||
<x-portal.table-pagination :paginator="$withdrawals" />
|
<x-portal.table-pagination :paginator="$withdrawals" />
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
{{-- ============== KÜNDIGUNGEN (Kündigungsbutton § 312k BGB) ============== --}}
|
||||||
|
<article class="panel overflow-hidden">
|
||||||
|
<div class="panel-head">
|
||||||
|
<span class="section-eyebrow">{{ __('Kündigungen') }}</span>
|
||||||
|
<div class="flex items-center gap-3">
|
||||||
|
<flux:select wire:model.live="terminationStatusFilter" size="sm" class="w-44">
|
||||||
|
<option value="open">{{ __('Offen') }}</option>
|
||||||
|
<option value="all">{{ __('Alle') }}</option>
|
||||||
|
<option value="resolved">{{ __('Erledigt') }}</option>
|
||||||
|
</flux:select>
|
||||||
|
<span class="text-[11.5px] text-[color:var(--color-ink-3)]">
|
||||||
|
{{ __(':count Einträge', ['count' => $terminations->total()]) }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<flux:table>
|
||||||
|
<flux:table.columns>
|
||||||
|
<flux:table.column>{{ __('Vorgang') }}</flux:table.column>
|
||||||
|
<flux:table.column>{{ __('Art') }}</flux:table.column>
|
||||||
|
<flux:table.column>{{ __('Name') }}</flux:table.column>
|
||||||
|
<flux:table.column>{{ __('E-Mail') }}</flux:table.column>
|
||||||
|
<flux:table.column>{{ __('Beendigung') }}</flux:table.column>
|
||||||
|
<flux:table.column>{{ __('Eingegangen') }}</flux:table.column>
|
||||||
|
<flux:table.column>{{ __('Status') }}</flux:table.column>
|
||||||
|
<flux:table.column>{{ __('Aktion') }}</flux:table.column>
|
||||||
|
</flux:table.columns>
|
||||||
|
|
||||||
|
<flux:table.rows>
|
||||||
|
@forelse ($terminations as $termination)
|
||||||
|
<flux:table.row :key="'termination-'.$termination->id">
|
||||||
|
<flux:table.cell>
|
||||||
|
<span class="text-[12.5px] font-mono font-semibold text-[color:var(--color-ink)]">
|
||||||
|
K-{{ $termination->id }}
|
||||||
|
</span>
|
||||||
|
</flux:table.cell>
|
||||||
|
<flux:table.cell>
|
||||||
|
<span class="text-[12.5px] text-[color:var(--color-ink)]">
|
||||||
|
{{ $termination->isExtraordinary() ? __('Außerordentlich') : __('Ordentlich') }}
|
||||||
|
</span>
|
||||||
|
@if ($termination->isExtraordinary() && $termination->reason)
|
||||||
|
<p class="text-[11.5px] text-[color:var(--color-ink-3)] m-0 mt-0.5 max-w-[220px]">
|
||||||
|
{{ \Illuminate\Support\Str::limit($termination->reason, 90) }}
|
||||||
|
</p>
|
||||||
|
@endif
|
||||||
|
</flux:table.cell>
|
||||||
|
<flux:table.cell>
|
||||||
|
<span class="text-[13px] font-semibold text-[color:var(--color-ink)]">
|
||||||
|
{{ $termination->name }}
|
||||||
|
</span>
|
||||||
|
@if ($termination->contract_reference)
|
||||||
|
<p class="text-[11.5px] text-[color:var(--color-ink-3)] m-0 mt-0.5">
|
||||||
|
{{ __('Vertrag/Rechnung:') }} {{ $termination->contract_reference }}
|
||||||
|
</p>
|
||||||
|
@endif
|
||||||
|
</flux:table.cell>
|
||||||
|
<flux:table.cell>
|
||||||
|
<a href="mailto:{{ $termination->email }}"
|
||||||
|
class="text-[12.5px] text-[color:var(--color-hub)] hover:underline">
|
||||||
|
{{ $termination->email }}
|
||||||
|
</a>
|
||||||
|
</flux:table.cell>
|
||||||
|
<flux:table.cell>
|
||||||
|
<span class="text-[12.5px] text-[color:var(--color-ink-2)]">
|
||||||
|
{{ $termination->terminate_at?->format('d.m.Y') ?? __('nächstmöglich') }}
|
||||||
|
</span>
|
||||||
|
</flux:table.cell>
|
||||||
|
<flux:table.cell>
|
||||||
|
<span class="text-[12px] text-[color:var(--color-ink-3)]">
|
||||||
|
{{ $termination->created_at?->format('d.m.Y H:i') ?? '-' }}
|
||||||
|
</span>
|
||||||
|
</flux:table.cell>
|
||||||
|
<flux:table.cell>
|
||||||
|
@if ($termination->status === 'open')
|
||||||
|
<span class="badge warn dot">{{ __('Offen') }}</span>
|
||||||
|
@else
|
||||||
|
<span class="badge ok dot">{{ __('Erledigt') }}</span>
|
||||||
|
@endif
|
||||||
|
</flux:table.cell>
|
||||||
|
<flux:table.cell>
|
||||||
|
@if ($termination->status === 'open')
|
||||||
|
<flux:button size="sm" variant="filled" icon="check"
|
||||||
|
wire:click="resolveTermination({{ $termination->id }})">
|
||||||
|
{{ __('Erledigt') }}
|
||||||
|
</flux:button>
|
||||||
|
@else
|
||||||
|
<flux:button size="sm" variant="filled" icon="arrow-uturn-left"
|
||||||
|
wire:click="reopenTermination({{ $termination->id }})">
|
||||||
|
{{ __('Wieder öffnen') }}
|
||||||
|
</flux:button>
|
||||||
|
@endif
|
||||||
|
</flux:table.cell>
|
||||||
|
</flux:table.row>
|
||||||
|
@empty
|
||||||
|
<flux:table.row>
|
||||||
|
<flux:table.cell colspan="8">
|
||||||
|
<div class="flex flex-col items-center justify-center px-4 py-10 text-center">
|
||||||
|
<div class="w-14 h-14 rounded-[6px] flex items-center justify-center mb-3
|
||||||
|
bg-[color:var(--color-hub-soft)] border border-[color:var(--color-hub-soft-2)] text-[color:var(--color-hub)]">
|
||||||
|
<flux:icon.no-symbol class="size-6" />
|
||||||
|
</div>
|
||||||
|
<div class="text-[14px] font-semibold text-[color:var(--color-ink)] mb-1">
|
||||||
|
{{ __('Keine Kündigungen in dieser Ansicht') }}
|
||||||
|
</div>
|
||||||
|
<p class="text-[12.5px] text-[color:var(--color-ink-3)] m-0 max-w-[420px]">
|
||||||
|
{{ __('Online-Kündigungen über den Kündigungsbutton (§ 312k BGB) laufen hier auf. Die Zugangsbestätigung an den Verbraucher wird automatisch versendet – der Beendigungszeitpunkt muss manuell bestätigt werden.') }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</flux:table.cell>
|
||||||
|
</flux:table.row>
|
||||||
|
@endforelse
|
||||||
|
</flux:table.rows>
|
||||||
|
</flux:table>
|
||||||
|
|
||||||
|
<x-portal.table-pagination :paginator="$terminations" />
|
||||||
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use App\Http\Controllers\Web\NewsroomsController;
|
||||||
use App\Http\Controllers\Web\PreiseController;
|
use App\Http\Controllers\Web\PreiseController;
|
||||||
use App\Http\Controllers\Web\ReleaseDetailController;
|
use App\Http\Controllers\Web\ReleaseDetailController;
|
||||||
use App\Http\Controllers\Web\SucheController;
|
use App\Http\Controllers\Web\SucheController;
|
||||||
|
use App\Http\Controllers\Web\TerminationController;
|
||||||
use App\Http\Controllers\Web\VeroeffentlichenController;
|
use App\Http\Controllers\Web\VeroeffentlichenController;
|
||||||
use App\Http\Middleware\SetEdition;
|
use App\Http\Middleware\SetEdition;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
|
|
@ -205,6 +206,13 @@ Route::prefix('{edition}')->whereIn('edition', SetEdition::EDITIONS)->group(func
|
||||||
Route::view('presse', 'web.presse')->name('presse');
|
Route::view('presse', 'web.presse')->name('presse');
|
||||||
Route::view('hilfe', 'web.hilfe')->name('hilfe');
|
Route::view('hilfe', 'web.hilfe')->name('hilfe');
|
||||||
Route::view('impressum', 'web.impressum')->name('impressum');
|
Route::view('impressum', 'web.impressum')->name('impressum');
|
||||||
|
|
||||||
|
// Gesetzlicher Kündigungsbutton (§ 312k BGB): öffentliche Bestätigungsseite
|
||||||
|
// + Eingang der Kündigungserklärung, ohne Login erreichbar.
|
||||||
|
Route::get('kuendigung', [TerminationController::class, 'show'])->name('kuendigung');
|
||||||
|
Route::post('kuendigung', [TerminationController::class, 'store'])
|
||||||
|
->middleware('throttle:10,1')
|
||||||
|
->name('kuendigung.store');
|
||||||
Route::view('datenschutz', 'web.datenschutz')->name('datenschutz');
|
Route::view('datenschutz', 'web.datenschutz')->name('datenschutz');
|
||||||
Route::view('agb', 'web.agb')->name('agb');
|
Route::view('agb', 'web.agb')->name('agb');
|
||||||
Route::view('cookies', 'web.cookies')->name('cookies');
|
Route::view('cookies', 'web.cookies')->name('cookies');
|
||||||
|
|
|
||||||
77
tests/Feature/Admin/TerminationRequestsAdminTest.php
Normal file
77
tests/Feature/Admin/TerminationRequestsAdminTest.php
Normal file
|
|
@ -0,0 +1,77 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\TerminationRequest;
|
||||||
|
use App\Models\User;
|
||||||
|
use Database\Seeders\RolesAndPermissionsSeeder;
|
||||||
|
use Livewire\Volt\Volt;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
beforeEach(function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
$this->seed(RolesAndPermissionsSeeder::class);
|
||||||
|
});
|
||||||
|
|
||||||
|
function terminationAdmin(): User
|
||||||
|
{
|
||||||
|
$admin = User::factory()->create(['is_active' => true]);
|
||||||
|
$admin->assignRole('admin');
|
||||||
|
|
||||||
|
return $admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
test('the legal queue lists open termination requests', function () {
|
||||||
|
$termination = TerminationRequest::factory()->extraordinary()->create([
|
||||||
|
'name' => 'Paula Presse',
|
||||||
|
'email' => 'paula@example.test',
|
||||||
|
'contract_reference' => 'STR-2026-0042',
|
||||||
|
'reason' => 'Wiederholte Störung der Leistung.',
|
||||||
|
]);
|
||||||
|
|
||||||
|
Volt::actingAs(terminationAdmin())
|
||||||
|
->test('admin.legal-requests.index')
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Kündigungen')
|
||||||
|
->assertSee('K-'.$termination->id)
|
||||||
|
->assertSee('Paula Presse')
|
||||||
|
->assertSee('paula@example.test')
|
||||||
|
->assertSee('STR-2026-0042')
|
||||||
|
->assertSee('Außerordentlich');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('an admin can resolve a termination request', function () {
|
||||||
|
$termination = TerminationRequest::factory()->create();
|
||||||
|
|
||||||
|
Volt::actingAs(terminationAdmin())
|
||||||
|
->test('admin.legal-requests.index')
|
||||||
|
->call('resolveTermination', $termination->id)
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
$termination->refresh();
|
||||||
|
|
||||||
|
expect($termination->status)->toBe('resolved');
|
||||||
|
expect($termination->resolved_at)->not->toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('an admin can reopen a resolved termination request', function () {
|
||||||
|
$termination = TerminationRequest::factory()->resolved()->create();
|
||||||
|
|
||||||
|
Volt::actingAs(terminationAdmin())
|
||||||
|
->test('admin.legal-requests.index')
|
||||||
|
->set('terminationStatusFilter', 'all')
|
||||||
|
->call('reopenTermination', $termination->id)
|
||||||
|
->assertOk();
|
||||||
|
|
||||||
|
$termination->refresh();
|
||||||
|
|
||||||
|
expect($termination->status)->toBe('open');
|
||||||
|
expect($termination->resolved_at)->toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('resolved terminations are hidden from the default open view', function () {
|
||||||
|
TerminationRequest::factory()->resolved()->create(['name' => 'Erledigte Kündigung']);
|
||||||
|
|
||||||
|
Volt::actingAs(terminationAdmin())
|
||||||
|
->test('admin.legal-requests.index')
|
||||||
|
->assertOk()
|
||||||
|
->assertDontSee('Erledigte Kündigung');
|
||||||
|
});
|
||||||
143
tests/Feature/Web/TerminationRequestTest.php
Normal file
143
tests/Feature/Web/TerminationRequestTest.php
Normal file
|
|
@ -0,0 +1,143 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Mail\TerminationRequestReceived;
|
||||||
|
use App\Mail\TerminationRequestSubmitted;
|
||||||
|
use App\Models\TerminationRequest;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
test('the hub footer shows the legally required termination button', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
$response = $this->get('https://pressekonto.test/')->assertSuccessful();
|
||||||
|
|
||||||
|
expect($response->getContent())
|
||||||
|
->toContain('Verträge hier kündigen')
|
||||||
|
->toContain(route('kuendigung', ['edition' => 'de']));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the termination confirmation page renders the § 312k form with the hub shell', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
$response = $this->get('https://pressekonto.test/de/kuendigung')->assertSuccessful();
|
||||||
|
$content = $response->getContent();
|
||||||
|
|
||||||
|
expect($content)
|
||||||
|
// Pflichtangaben der Bestätigungsseite (§ 312k Abs. 2 BGB).
|
||||||
|
->toContain('Ordentliche Kündigung')
|
||||||
|
->toContain('Außerordentliche Kündigung')
|
||||||
|
->toContain('name="kind"')
|
||||||
|
->toContain('name="reason"')
|
||||||
|
->toContain('name="terminate_mode"')
|
||||||
|
->toContain('Zum nächstmöglichen Zeitpunkt')
|
||||||
|
// Bestätigungsschaltfläche mit gesetzeskonformer Aufschrift.
|
||||||
|
->toContain('jetzt kündigen')
|
||||||
|
// Hub-Gerüst (host-aware static-page).
|
||||||
|
->toContain('Publisher · Hub');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('an ordinary termination is persisted and both mails are sent immediately', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
Mail::fake();
|
||||||
|
config()->set('domains.domains.pressekonto.brand.contact_email', 'kontakt@pressekonto.de');
|
||||||
|
|
||||||
|
$this->from('https://pressekonto.test/de/kuendigung')
|
||||||
|
->post('https://pressekonto.test/de/kuendigung', [
|
||||||
|
'kind' => 'ordentlich',
|
||||||
|
'name' => 'Paula Presse',
|
||||||
|
'email' => 'paula@example.test',
|
||||||
|
'contract_reference' => 'STR-2026-0042',
|
||||||
|
'terminate_mode' => 'asap',
|
||||||
|
])
|
||||||
|
->assertRedirect('https://pressekonto.test/de/kuendigung')
|
||||||
|
->assertSessionHas('termination-status');
|
||||||
|
|
||||||
|
$request = TerminationRequest::query()->firstOrFail();
|
||||||
|
|
||||||
|
expect($request->kind)->toBe('ordentlich');
|
||||||
|
expect($request->reason)->toBeNull();
|
||||||
|
expect($request->name)->toBe('Paula Presse');
|
||||||
|
expect($request->email)->toBe('paula@example.test');
|
||||||
|
expect($request->contract_reference)->toBe('STR-2026-0042');
|
||||||
|
expect($request->terminate_at)->toBeNull();
|
||||||
|
expect($request->host)->toBe('pressekonto.test');
|
||||||
|
expect($request->status)->toBe('open');
|
||||||
|
|
||||||
|
// § 312k Abs. 4 BGB: sofortige automatische Zugangsbestätigung.
|
||||||
|
Mail::assertSent(TerminationRequestReceived::class, fn (TerminationRequestReceived $mail) => $mail->hasTo('paula@example.test'));
|
||||||
|
Mail::assertSent(TerminationRequestSubmitted::class, fn (TerminationRequestSubmitted $mail) => $mail->hasTo('kontakt@pressekonto.de'));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('an extraordinary termination requires a reason', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
Mail::fake();
|
||||||
|
|
||||||
|
$this->post('https://pressekonto.test/de/kuendigung', [
|
||||||
|
'kind' => 'ausserordentlich',
|
||||||
|
'name' => 'Paula Presse',
|
||||||
|
'email' => 'paula@example.test',
|
||||||
|
'terminate_mode' => 'asap',
|
||||||
|
])->assertSessionHasErrorsIn('termination', ['reason']);
|
||||||
|
|
||||||
|
expect(TerminationRequest::query()->count())->toBe(0);
|
||||||
|
Mail::assertNothingSent();
|
||||||
|
|
||||||
|
$this->post('https://pressekonto.test/de/kuendigung', [
|
||||||
|
'kind' => 'ausserordentlich',
|
||||||
|
'reason' => 'Wiederholte Störung der Leistung.',
|
||||||
|
'name' => 'Paula Presse',
|
||||||
|
'email' => 'paula@example.test',
|
||||||
|
'terminate_mode' => 'asap',
|
||||||
|
])->assertSessionHas('termination-status');
|
||||||
|
|
||||||
|
expect(TerminationRequest::query()->firstOrFail()->reason)->toBe('Wiederholte Störung der Leistung.');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('a termination to a specific date requires and persists the date', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
Mail::fake();
|
||||||
|
|
||||||
|
$this->post('https://pressekonto.test/de/kuendigung', [
|
||||||
|
'kind' => 'ordentlich',
|
||||||
|
'name' => 'Paula Presse',
|
||||||
|
'email' => 'paula@example.test',
|
||||||
|
'terminate_mode' => 'date',
|
||||||
|
])->assertSessionHasErrorsIn('termination', ['terminate_at']);
|
||||||
|
|
||||||
|
$this->post('https://pressekonto.test/de/kuendigung', [
|
||||||
|
'kind' => 'ordentlich',
|
||||||
|
'name' => 'Paula Presse',
|
||||||
|
'email' => 'paula@example.test',
|
||||||
|
'terminate_mode' => 'date',
|
||||||
|
'terminate_at' => '2026-08-31',
|
||||||
|
])->assertSessionHas('termination-status');
|
||||||
|
|
||||||
|
expect(TerminationRequest::query()->firstOrFail()->terminate_at->format('Y-m-d'))->toBe('2026-08-31');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('termination validation errors land in the termination error bag', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
Mail::fake();
|
||||||
|
|
||||||
|
$this->post('https://pressekonto.test/de/kuendigung', [
|
||||||
|
'name' => '',
|
||||||
|
'email' => 'keine-mail',
|
||||||
|
])->assertSessionHasErrorsIn('termination', ['kind', 'name', 'email', 'terminate_mode']);
|
||||||
|
|
||||||
|
expect(TerminationRequest::query()->count())->toBe(0);
|
||||||
|
Mail::assertNothingSent();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('honeypot submissions are silently accepted without persisting or mailing', function () {
|
||||||
|
/** @var TestCase $this */
|
||||||
|
Mail::fake();
|
||||||
|
|
||||||
|
$this->post('https://pressekonto.test/de/kuendigung', [
|
||||||
|
'kind' => 'ordentlich',
|
||||||
|
'name' => 'Bot',
|
||||||
|
'email' => 'bot@example.test',
|
||||||
|
'terminate_mode' => 'asap',
|
||||||
|
'website' => 'https://spam.example',
|
||||||
|
])->assertSessionHas('termination-status');
|
||||||
|
|
||||||
|
expect(TerminationRequest::query()->count())->toBe(0);
|
||||||
|
Mail::assertNothingSent();
|
||||||
|
});
|
||||||
Loading…
Add table
Add a link
Reference in a new issue