Passed
Pull Request — master (#89)
by
unknown
40:26
created

AccountController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 7
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Domains\Users\GetUserDetails;
6
use App\Domains\Users\SetUserDetails;
7
8
use App\Http\Requests\UserBasicAccountRequest;
9
use App\Http\Requests\UserChangePasswordRequest;
10
use App\Http\Requests\UserNotificationSettingsRequest;
11
12
class AccountController extends Controller
13
{
14 26
    public function __construct()
15
    {
16 26
        $this->middleware('auth');
17 26
    }
18
19
    //  Index page is the change user settings form
20 2
    public function index()
21
    {
22 2
        $userObj = new GetUserDetails;
23
24 2
        return view('account.index', [
25 2
            'userData'     => $userObj->getUserData(),
26 2
            'userSettings' => $userObj->getUserSettings(),
27
        ]);
28
    }
29
30
    //  Submit the new user settings
31 2
    public function submit(UserBasicAccountRequest $request)
32
    {
33 2
        (new SetUserDetails)->updateUserDetails($request);
34 2
        return response()->json(['success' => true]);
35
    }
36
37
    //  Submit the user notification settings
38 2
    public function notifications(UserNotificationSettingsRequest $request)
39
    {
40 2
        (new SetUserDetails)->updateUserNotifications($request);
41 2
        return response()->json(['success' => true]);
42
    }
43
44
    //  Bring up the change password form
45 2
    public function changePassword()
46
    {
47 2
        return view('account.changePassword');
48
    }
49
50
    //  Submit the change password form
51 2
    public function submitPassword(UserChangePasswordRequest $request)
52
    {
53 2
        (new SetUserDetails)->updateUserPassword($request);
54 2
        return redirect(route('account'))->with('success', 'Password Changed Successfully');
55
    }
56
}
57