|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use App\Http\Requests\ContactContactURequest; |
|
6
|
|
|
use App\Jobs\SendContactUsEmail; |
|
7
|
|
|
|
|
8
|
|
|
class ContactUsController extends BasePageController |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @throws \Illuminate\Validation\ValidationException |
|
12
|
|
|
*/ |
|
13
|
|
|
public function contact(ContactContactURequest $request) |
|
14
|
|
|
{ |
|
15
|
|
|
|
|
16
|
|
|
$msg = ''; |
|
17
|
|
|
|
|
18
|
|
|
if ($request->has('useremail')) { |
|
19
|
|
|
$email = $request->input('useremail'); |
|
20
|
|
|
$mailTo = config('mail.from.address'); |
|
21
|
|
|
$mailBody = 'Values submitted from contact form: '; |
|
22
|
|
|
|
|
23
|
|
|
$captchaFieldName = \App\Support\CaptchaHelper::getResponseFieldName(); |
|
|
|
|
|
|
24
|
|
|
foreach ($request->all() as $key => $value) { |
|
25
|
|
|
if ($key !== 'submit' && $key !== '_token' && $key !== 'g-recaptcha-response' && $key !== 'cf-turnstile-response') { |
|
26
|
|
|
$mailBody .= "$key : $value".PHP_EOL; |
|
27
|
|
|
} |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
if (! preg_match("/\n/i", $request->input('useremail'))) { |
|
31
|
|
|
SendContactUsEmail::dispatch($email, $mailTo, $mailBody)->onQueue('contactemail'); |
|
32
|
|
|
} |
|
33
|
|
|
$msg = "<h2 style='text-align:center;'>Thank you for getting in touch with ".config('app.name').'.</h2>'; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
return $this->showContactForm($msg); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return \Illuminate\View\View |
|
41
|
|
|
* |
|
42
|
|
|
* @throws \Exception |
|
43
|
|
|
*/ |
|
44
|
|
|
public function showContactForm(string $msg = '') |
|
45
|
|
|
{ |
|
46
|
|
|
return view('contact.index', [ |
|
47
|
|
|
'title' => 'Contact '.config('app.name'), |
|
48
|
|
|
'meta_title' => 'Contact '.config('app.name'), |
|
49
|
|
|
'meta_keywords' => 'contact us,contact,get in touch,email', |
|
50
|
|
|
'meta_description' => 'Contact us at '.config('app.name').' and submit your feedback', |
|
51
|
|
|
'msg' => $msg, |
|
52
|
|
|
]); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|