Stories 0.2-0.5: rename folders→declarations (backend+frontend), configure Redis for cache/queue/sessions, add foundation database migrations (permissions, archived_at), replace DeclarationStatus enum with architecture lifecycle values, create DeclarationObserver for status transition validation and auto-archive, fix controller status transitions to respect observer rules. 93 tests pass (240 assertions). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
58 lines
1.7 KiB
PHP
58 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Client;
|
|
|
|
use App\Enums\ActorType;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
class ConfirmController extends Controller
|
|
{
|
|
/**
|
|
* Show the confirmation page.
|
|
*/
|
|
public function show(Request $request, string $token): Response
|
|
{
|
|
$invitation = $request->attributes->get('declaration_invitation');
|
|
$declaration = $invitation->declaration;
|
|
|
|
$declaration->load(['client']);
|
|
|
|
return Inertia::render('client/Confirm', [
|
|
'declaration' => [
|
|
'id' => $declaration->id,
|
|
'title' => $declaration->title,
|
|
'client_name' => $declaration->client->company_name,
|
|
],
|
|
'token' => $token,
|
|
'submitUrl' => route('client.confirm.store', ['token' => $token]),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Store the confirmation (client confirms).
|
|
*/
|
|
public function store(Request $request, string $token): RedirectResponse
|
|
{
|
|
$invitation = $request->attributes->get('declaration_invitation');
|
|
$declaration = $invitation->declaration;
|
|
|
|
$request->validate([
|
|
'signature' => ['required', 'string', 'max:255'],
|
|
]);
|
|
|
|
$declaration->update([
|
|
'validated_at' => now(),
|
|
'confirmed_by_type' => ActorType::Client,
|
|
'confirmed_by_id' => $declaration->client_id,
|
|
'confirmation_signature' => $request->input('signature'),
|
|
'status' => \App\Enums\DeclarationStatus::EnCours,
|
|
]);
|
|
|
|
return back()->with('flash', ['type' => 'success', 'message' => 'Validation enregistrée. Merci.']);
|
|
}
|
|
}
|