Passed
Branch dev5a (b4693d)
by Ron
27:36
created

SettingsController::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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
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\Auth;
4
5
use App\Http\Controllers\Controller;
6
7
use Illuminate\Support\Facades\Auth;
8
9
use App\Domains\User\GetUserDetails;
10
use App\Domains\User\SetUserDetails;
11
12
use App\Http\Requests\User\UserAccountRequest;
13
use App\Http\Requests\User\UserPasswordRequest;
14
use App\Http\Requests\User\UserSettingsRequest;
15
16
class SettingsController extends Controller
17
{
18 2
    public function index()
19
    {
20 2
        $userObj = new GetUserDetails(Auth::user()->user_id);
21
22 2
        return view('auth.settings', [
23 2
            'userData' => $userObj->getUserData(),
24 2
            'userSett' => $userObj->getUserSettings(),
25
        ]);
26
    }
27
28 2
    public function updateAccount(UserAccountRequest $request)
29
    {
30 2
        (new SetUserDetails)->updateUser($request, Auth::user()->user_id);
31 2
        return response()->json(['success' => true]);
32
    }
33
34 2
    public function updateSettings(UserSettingsRequest $request)
35
    {
36 2
        (new SetUserDetails)->updateSettings($request, Auth::user()->user_id);
37 2
        return response()->json(['success' => true]);
38
    }
39
40 2
    public function changePassword(UserPasswordRequest $request)
41
    {
42 2
        (new SetUserDetails)->updatePassword($request->password, Auth::user()->user_id);
43 2
        return response()->json(['success' => true]);
44
    }
45
}
46