Completed
Push — master ( baf737...1f6f50 )
by Jeremy
08:14
created

ContactController::contactSend()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Http\Requests\ContactRequest;
6
use App\Mail\ContactMail;
7
use Illuminate\Support\Facades\Mail;
8
9
class ContactController extends Controller
10
{
11
    /**
12
     * Show the application contact page.
13
     *
14
     * @return \Illuminate\Http\Response
15
     */
16
    public function index()
17
    {
18
        $pageData = [
19
            'pageTitle' => trans('larablog.contact.pageTitle'),
20
            'pageDesc'  => trans('larablog.contact.pageDesc'),
21
            'title'     => trans('larablog.contact.title'),
22
            'subtitle'  => trans('larablog.contact.subtitle'),
23
            'image'     => config('blog.contact_page_image'),
24
        ];
25
26
        return view('blog.pages.contact', $pageData);
0 ignored issues
show
Bug Best Practice introduced by
The expression return view('blog.pages.contact', $pageData) returns the type Illuminate\View\View which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
27
    }
28
29
    /**
30
     * Send Contact Email Function via Mail.
31
     *
32
     * @return \Illuminate\Http\Response
33
     */
34
    public function contactSend(ContactRequest $request)
35
    {
36
        $validatedData = $request->validated();
37
38
        Mail::to(config('blog.contact_email'))->send(new ContactMail($validatedData));
39
40
        return back()->withSuccess(trans('forms.contact.messages.sent'));
0 ignored issues
show
Bug Best Practice introduced by
The expression return back()->withSucce...ontact.messages.sent')) also could return the type Illuminate\Http\RedirectResponse which is incompatible with the documented return type Illuminate\Http\Response.
Loading history...
41
    }
42
}
43