Issues (378)

app/Http/Controllers/ContactUsController.php (1 issue)

Labels
Severity
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
        $this->setPreferences();
16
17
        if (config('captcha.enabled') === true && (! empty(config('captcha.secret')) && ! empty(config('captcha.sitekey')))) {
18
            $this->validate($request, [
19
                'g-recaptcha-response' => 'required|captcha',
20
            ]);
21
        }
22
23
        $msg = '';
24
25
        if ($request->has('useremail')) {
26
            $email = $request->input('useremail');
27
            $mailTo = config('mail.from.address');
28
            $mailBody = 'Values submitted from contact form: ';
29
30
            foreach ($request->all() as $key => $value) {
31
                if ($key !== 'submit' && $key !== '_token' && $key !== 'g-recaptcha-response') {
32
                    $mailBody .= "$key : $value".PHP_EOL;
33
                }
34
            }
35
36
            if (! preg_match("/\n/i", $request->input('useremail'))) {
37
                SendContactUsEmail::dispatch($email, $mailTo, $mailBody)->onQueue('contactemail');
38
            }
39
            $msg = "<h2 style='text-align:center;'>Thank you for getting in touch with ".config('app.name').'.</h2>';
40
        }
41
42
        return $this->showContactForm($msg);
0 ignored issues
show
Are you sure the usage of $this->showContactForm($msg) targeting App\Http\Controllers\Con...ller::showContactForm() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
43
    }
44
45
    /**
46
     * @return void
47
     *
48
     * @throws \Exception
49
     */
50
    public function showContactForm(string $msg = '')
51
    {
52
        $this->setPreferences();
53
        $title = 'Contact '.config('app.name');
54
        $meta_title = 'Contact '.config('app.name');
55
        $meta_keywords = 'contact us,contact,get in touch,email';
56
        $meta_description = 'Contact us at '.config('app.name').' and submit your feedback';
57
        $content = $this->smarty->fetch('contact.tpl');
58
59
        $this->smarty->assign(compact('title', 'content', 'meta_title', 'meta_keywords', 'meta_description', 'msg'));
60
61
        $this->pagerender();
62
    }
63
}
64