2026-03-11 23:33:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Client;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Inertia\Inertia;
|
|
|
|
|
use Inertia\Response;
|
|
|
|
|
|
|
|
|
|
class RefuseController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Show the refusal page.
|
|
|
|
|
*/
|
|
|
|
|
public function show(Request $request, string $token): Response
|
|
|
|
|
{
|
2026-03-12 18:25:32 +00:00
|
|
|
$invitation = $request->attributes->get('declaration_invitation');
|
|
|
|
|
$declaration = $invitation->declaration;
|
2026-03-11 23:33:10 +00:00
|
|
|
|
2026-03-12 18:25:32 +00:00
|
|
|
$declaration->load(['client']);
|
2026-03-11 23:33:10 +00:00
|
|
|
|
|
|
|
|
return Inertia::render('client/Refuse', [
|
2026-03-12 18:25:32 +00:00
|
|
|
'declaration' => [
|
|
|
|
|
'id' => $declaration->id,
|
|
|
|
|
'title' => $declaration->title,
|
|
|
|
|
'client_name' => $declaration->client->company_name,
|
2026-03-11 23:33:10 +00:00
|
|
|
],
|
|
|
|
|
'token' => $token,
|
|
|
|
|
'submitUrl' => route('client.refuse.store', ['token' => $token]),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Store the refusal.
|
|
|
|
|
*/
|
|
|
|
|
public function store(Request $request, string $token): RedirectResponse
|
|
|
|
|
{
|
2026-03-12 18:25:32 +00:00
|
|
|
$invitation = $request->attributes->get('declaration_invitation');
|
|
|
|
|
$declaration = $invitation->declaration;
|
2026-03-11 23:33:10 +00:00
|
|
|
|
|
|
|
|
$request->validate([
|
|
|
|
|
'reason' => ['nullable', 'string', 'max:65535'],
|
|
|
|
|
]);
|
|
|
|
|
|
2026-03-12 18:25:32 +00:00
|
|
|
$declaration->update([
|
2026-03-11 23:33:10 +00:00
|
|
|
'refused_at' => now(),
|
|
|
|
|
'refusal_reason' => $request->input('reason'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
return back()->with('flash', ['type' => 'success', 'message' => 'Refus enregistré.']);
|
|
|
|
|
}
|
|
|
|
|
}
|