Skip to content

Commit 170eca9

Browse files
Address code review: try-catch on mail, remove novalidate, config-driven title, error flash
Co-authored-by: delicatacurtis <247246500+delicatacurtis@users.noreply.github.com>
1 parent 6e84371 commit 170eca9

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

app/Http/Controllers/ContactController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ public function submit(Request $request)
2323
'message' => ['required', 'string', 'max:5000'],
2424
]);
2525

26-
Mail::to('office@liberu.co.uk')->send(new ContactMail($validated));
26+
try {
27+
Mail::to('office@liberu.co.uk')->send(new ContactMail($validated));
28+
} catch (\Exception $e) {
29+
return redirect()->route('contact')
30+
->withInput()
31+
->with('error', 'Sorry, we were unable to send your message. Please try contacting us directly at support@liberu.co.uk.');
32+
}
2733

2834
return redirect()->route('contact')
2935
->with('success', 'Thank you for your message. We will be in touch shortly.');

resources/views/contact.blade.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,14 @@
5454
<div class="lg:col-span-3">
5555
<div class="bg-neutral-800/60 border border-neutral-700/60 rounded-xl p-7 sm:p-8">
5656

57+
{{-- Error flash (mail failure) --}}
58+
@if(session('error'))
59+
<div class="mb-6 flex items-start gap-3 bg-red-900/40 border border-red-700/50 text-red-300 rounded-lg px-4 py-3 text-sm">
60+
<svg class="w-5 h-5 shrink-0 mt-0.5" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m9-.75a9 9 0 11-18 0 9 9 0 0118 0zm-9 3.75h.008v.008H12v-.008z"/></svg>
61+
{{ session('error') }}
62+
</div>
63+
@endif
64+
5765
{{-- Success message --}}
5866
@if(session('success'))
5967
<div class="mb-6 flex items-start gap-3 bg-green-900/40 border border-green-700/50 text-green-300 rounded-lg px-4 py-3 text-sm">
@@ -76,7 +84,7 @@
7684
</div>
7785
@endif
7886

79-
<form method="POST" action="{{ route('contact.submit') }}" novalidate>
87+
<form method="POST" action="{{ route('contact.submit') }}">
8088
@csrf
8189

8290
<div class="grid grid-cols-1 sm:grid-cols-2 gap-5 mb-5">

resources/views/layouts/guest.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="robots" content="index, follow">
77

88
{{-- Page title --}}
9-
<title>@yield('page_title', 'Liberu Software') | Liberu Software</title>
9+
<title>@yield('page_title', config('app.name', 'Liberu Software')) | {{ config('app.name', 'Liberu Software') }}</title>
1010

1111
{{-- Primary meta description --}}
1212
<meta name="description" content="@yield('meta_description', 'Liberu Software delivers enterprise-grade, open-source Laravel applications — from CRM and accounting to e-commerce and genealogy — built for modern businesses.')">

0 commit comments

Comments
 (0)