mirror of
https://github.com/rico-vz/HeimerdingerLoL.git
synced 2025-12-06 10:10:48 +01:00
feat(contact): Add hCaptcha integration, Discord alert for contact
- Added hCaptcha validation to the contact form. - Integrated hCaptcha configuration in the application. - Implemented Discord alerts for new contact submissions with detailed content.
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests\ContactSubmissionRequest;
|
||||
use App\Models\ContactSubmission;
|
||||
use Spatie\DiscordAlerts\Facades\DiscordAlert;
|
||||
|
||||
class ContactSubmissionController extends Controller
|
||||
{
|
||||
@@ -16,6 +17,20 @@ class ContactSubmissionController extends Controller
|
||||
{
|
||||
$contactSubmission = ContactSubmission::create($request->validated());
|
||||
|
||||
$descriptionContent = "**Name**: {$contactSubmission->name}\n\n**Email**: {$contactSubmission->email}\n\n**Category**: {$contactSubmission->category->humanReadable()}\n\n**Subject**: {$contactSubmission->subject}\n\n**Message**: {$contactSubmission->message}";
|
||||
|
||||
if ($contactSubmission->discord) {
|
||||
$descriptionContent .= "\n\n\n**Discord**: {$contactSubmission->discord}";
|
||||
}
|
||||
|
||||
DiscordAlert::message("There is a new contact submission from {$contactSubmission->name} ({$contactSubmission->email}).", [
|
||||
[
|
||||
'title' => "{$contactSubmission->category->humanReadable()} - {$contactSubmission->subject}",
|
||||
'description' => $descriptionContent,
|
||||
'color' => '#ff8a4c',
|
||||
]
|
||||
]);
|
||||
|
||||
return redirect()->route('contact.index')->with('success', 'Your message has been sent!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ class ContactSubmissionRequest extends FormRequest
|
||||
return [
|
||||
'name' => ['required', 'max:254'],
|
||||
'email' => ['required', 'email', 'max:254'],
|
||||
'discord' => ['nullable', 'min:2', 'max:34'],
|
||||
'discord' => ['nullable', 'min:2', 'max:35'],
|
||||
'category' => ['required', 'in:question,advertising,bug_report,feedback,other'],
|
||||
'subject' => ['required', 'max:254'],
|
||||
'message' => ['required', 'unique:contact_submissions', 'max:3500'],
|
||||
'h-captcha-response' => 'required|HCaptcha'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -22,4 +23,14 @@ class ContactSubmissionRequest extends FormRequest
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function messages(): array
|
||||
{
|
||||
return [
|
||||
'h-captcha-response.required' => 'Please verify that you are not a robot.',
|
||||
'h-captcha-response.h_captcha' => 'Failed to validate captcha.',
|
||||
'category.in' => 'Invalid category.',
|
||||
'message.unique' => 'You have already submitted this message.',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user