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
|
|
|
|