54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
|
|
<?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
|
||
|
|
{
|
||
|
|
$invitation = $request->attributes->get('folder_invitation');
|
||
|
|
$folder = $invitation->folder;
|
||
|
|
|
||
|
|
$folder->load(['client']);
|
||
|
|
|
||
|
|
return Inertia::render('client/Refuse', [
|
||
|
|
'folder' => [
|
||
|
|
'id' => $folder->id,
|
||
|
|
'title' => $folder->title,
|
||
|
|
'client_name' => $folder->client->company_name,
|
||
|
|
],
|
||
|
|
'token' => $token,
|
||
|
|
'submitUrl' => route('client.refuse.store', ['token' => $token]),
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Store the refusal.
|
||
|
|
*/
|
||
|
|
public function store(Request $request, string $token): RedirectResponse
|
||
|
|
{
|
||
|
|
$invitation = $request->attributes->get('folder_invitation');
|
||
|
|
$folder = $invitation->folder;
|
||
|
|
|
||
|
|
$request->validate([
|
||
|
|
'reason' => ['nullable', 'string', 'max:65535'],
|
||
|
|
]);
|
||
|
|
|
||
|
|
$folder->update([
|
||
|
|
'refused_at' => now(),
|
||
|
|
'refusal_reason' => $request->input('reason'),
|
||
|
|
]);
|
||
|
|
|
||
|
|
return back()->with('flash', ['type' => 'success', 'message' => 'Refus enregistré.']);
|
||
|
|
}
|
||
|
|
}
|