feat(Contact & membership forms update with their notification)
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 26h10m46s
All checks were successful
Deploy Roxane to Preprod / deploy (push) Successful in 26h10m46s
This commit is contained in:
@@ -7,32 +7,33 @@ use App\Http\Requests\Forms\ContactRequest;
|
||||
use App\Services\ContactService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class ContactFormController extends Controller
|
||||
{
|
||||
public function __construct(protected ContactService $contactService) {}
|
||||
/**
|
||||
* Show the contact form page.
|
||||
*/
|
||||
public function create()
|
||||
|
||||
public function create(): Response
|
||||
{
|
||||
return Inertia::render('forms/contact');
|
||||
return Inertia::render('forms/contact', [
|
||||
'captcha_question' => $this->generateCaptcha(),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming contact form submission.
|
||||
* @throws \Illuminate\Validation\ValidationException
|
||||
*/
|
||||
public function store(ContactRequest $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validated();
|
||||
|
||||
try {
|
||||
$this->contactService->registerNewContactRequest($validated);
|
||||
} catch (\Throwable $e) {
|
||||
\Log::error('Erreur lors de la création d\'un contact', [
|
||||
'error' => $e->getMessage(),
|
||||
'trace' => $e->getTraceAsString(),
|
||||
'data' => $validated,
|
||||
'data' => $validated,
|
||||
]);
|
||||
|
||||
return to_route('contact')->with('error', __('contacts.responses.error'));
|
||||
@@ -41,4 +42,13 @@ class ContactFormController extends Controller
|
||||
return to_route('contact')->with('success', __('contacts.responses.success'));
|
||||
}
|
||||
|
||||
private function generateCaptcha(): string
|
||||
{
|
||||
$a = random_int(1, 9);
|
||||
$b = random_int(1, 9);
|
||||
|
||||
session(['captcha_contact' => (string) ($a + $b)]);
|
||||
|
||||
return "Combien font {$a} + {$b} ?";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user