|
1
|
|
|
<?php namespace Arcanesoft\Auth\Http\Controllers\Admin; |
|
2
|
|
|
|
|
3
|
|
|
use Arcanesoft\Auth\Http\Requests\Admin\Profile\UpdatePasswordRequest; |
|
4
|
|
|
use Arcanesoft\Contracts\Auth\Models\User; |
|
5
|
|
|
use Log; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class ProfileController |
|
9
|
|
|
* |
|
10
|
|
|
* @package Arcanesoft\Auth\Http\Controllers\Admin |
|
11
|
|
|
* @author ARCANEDEV <[email protected]> |
|
12
|
|
|
* |
|
13
|
|
|
* @todo: Adding the authorization checks |
|
14
|
|
|
*/ |
|
15
|
|
|
class ProfileController extends Controller |
|
16
|
|
|
{ |
|
17
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
18
|
|
|
| Properties |
|
19
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
20
|
|
|
*/ |
|
21
|
|
|
/** |
|
22
|
|
|
* The authenticated user. |
|
23
|
|
|
* |
|
24
|
|
|
* @var \Arcanesoft\Contracts\Auth\Models\User |
|
25
|
|
|
*/ |
|
26
|
|
|
protected $user; |
|
27
|
|
|
|
|
28
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
29
|
|
|
| Constructor |
|
30
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
31
|
|
|
*/ |
|
32
|
|
|
/** |
|
33
|
|
|
* ProfileController constructor. |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct() |
|
36
|
|
|
{ |
|
37
|
|
|
parent::__construct(); |
|
38
|
|
|
|
|
39
|
|
|
$this->addBreadcrumbRoute('Profile', 'admin::auth.profile.index'); |
|
40
|
|
|
$this->setCurrentPage('auth-profile'); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
44
|
|
|
| Main Functions |
|
45
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
46
|
|
|
*/ |
|
47
|
|
|
public function index() |
|
48
|
|
|
{ |
|
49
|
|
|
$user = $this->getAuthenticatedUser(); |
|
50
|
|
|
|
|
51
|
|
|
$this->setTitle("Profile - {$user->full_name}"); |
|
|
|
|
|
|
52
|
|
|
$this->addBreadcrumbRoute($user->full_name, 'admin::auth.profile.index'); |
|
|
|
|
|
|
53
|
|
|
|
|
54
|
|
|
return $this->view('admin.profile.index', compact('user')); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function edit() |
|
58
|
|
|
{ |
|
59
|
|
|
// TODO: complete the implementation |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function update() |
|
63
|
|
|
{ |
|
64
|
|
|
// TODO: complete the implementation |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function updatePassword(UpdatePasswordRequest $request, User $user) |
|
68
|
|
|
{ |
|
69
|
|
|
$user->update([ |
|
|
|
|
|
|
70
|
|
|
'password' => $request->get('password'), |
|
71
|
|
|
]); |
|
72
|
|
|
|
|
73
|
|
|
Log::info($message = 'The password was updated successfully !', $user->toArray()); |
|
|
|
|
|
|
74
|
|
|
$this->notifySuccess($message, 'Password Updated !'); |
|
75
|
|
|
|
|
76
|
|
|
return redirect()->route('admin::auth.profile.index'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/* ------------------------------------------------------------------------------------------------ |
|
80
|
|
|
| Other Functions |
|
81
|
|
|
| ------------------------------------------------------------------------------------------------ |
|
82
|
|
|
*/ |
|
83
|
|
|
/** |
|
84
|
|
|
* Get the authenticated user. |
|
85
|
|
|
* |
|
86
|
|
|
* @return \Arcanesoft\Contracts\Auth\Models\User |
|
87
|
|
|
*/ |
|
88
|
|
|
private function getAuthenticatedUser() |
|
89
|
|
|
{ |
|
90
|
|
|
return auth()->user(); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: