1
|
|
|
<?php namespace Arcanesoft\Auth\Http\Controllers\Foundation; |
2
|
|
|
|
3
|
|
|
use Arcanesoft\Auth\Http\Requests\Backend\Profile\UpdatePasswordRequest; |
4
|
|
|
use Arcanesoft\Contracts\Auth\Models\User; |
5
|
|
|
use Log; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class ProfileController |
9
|
|
|
* |
10
|
|
|
* @package Arcanesoft\Auth\Http\Controllers\Foundation |
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->setCurrentPage('auth-profile'); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/* ------------------------------------------------------------------------------------------------ |
43
|
|
|
| Main Functions |
44
|
|
|
| ------------------------------------------------------------------------------------------------ |
45
|
|
|
*/ |
46
|
|
|
public function index() |
47
|
|
|
{ |
48
|
|
|
$user = $this->getAuthenticatedUser(); |
49
|
|
|
|
50
|
|
|
$this->setTitle($title = 'Profile - ' . $user->full_name); |
|
|
|
|
51
|
|
|
$this->addBreadcrumbRoute($title, 'auth::foundation.profile.index'); |
52
|
|
|
|
53
|
|
|
return $this->view('foundation.profile.index', compact('user')); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function updatePassword(UpdatePasswordRequest $request, User $user) |
57
|
|
|
{ |
58
|
|
|
$user->password = $request->get('password'); |
|
|
|
|
59
|
|
|
$user->save(); |
60
|
|
|
|
61
|
|
|
$message = 'The password was updated successfully !'; |
62
|
|
|
Log::info($message, $user->toArray()); |
|
|
|
|
63
|
|
|
$this->notifySuccess($message, 'Password Updated !'); |
64
|
|
|
|
65
|
|
|
return redirect()->route('auth::foundation.profile.index'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/* ------------------------------------------------------------------------------------------------ |
69
|
|
|
| Other Functions |
70
|
|
|
| ------------------------------------------------------------------------------------------------ |
71
|
|
|
*/ |
72
|
|
|
/** |
73
|
|
|
* Get the authenticated user. |
74
|
|
|
* |
75
|
|
|
* @return \Arcanesoft\Contracts\Auth\Models\User |
76
|
|
|
*/ |
77
|
|
|
private function getAuthenticatedUser() |
78
|
|
|
{ |
79
|
|
|
return auth()->user(); |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
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: