1
|
|
|
<?php namespace Arcanesoft\Auth\Http\Requests\Admin\Profile; |
2
|
|
|
|
3
|
|
|
use Arcanesoft\Auth\Http\Requests\FormRequest; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class UpdatePasswordRequest |
7
|
|
|
* |
8
|
|
|
* @package Arcanesoft\Auth\Http\Requests\Admin\Profile |
9
|
|
|
* @author ARCANEDEV <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
class UpdatePasswordRequest extends FormRequest |
12
|
|
|
{ |
13
|
|
|
/* ----------------------------------------------------------------- |
14
|
|
|
| Main Methods |
15
|
|
|
| ----------------------------------------------------------------- |
16
|
|
|
*/ |
17
|
|
|
/** |
18
|
|
|
* Determine if the user is authorized to make this request. |
19
|
|
|
* |
20
|
|
|
* @return bool |
21
|
|
|
*/ |
22
|
|
|
public function authorize() |
23
|
|
|
{ |
24
|
|
|
/** @var \Arcanesoft\Contracts\Auth\Models\User $user */ |
25
|
|
|
$user = $this->route('auth_user'); |
26
|
|
|
|
27
|
|
|
return $user->id === auth()->user()->id; |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Get the validation rules that apply to the request. |
32
|
|
|
* |
33
|
|
|
* @return array |
34
|
|
|
*/ |
35
|
|
|
public function rules() |
36
|
|
|
{ |
37
|
|
|
return [ |
38
|
|
|
'old_password' => ['required', 'string', 'min:8', 'different:password', 'user_password'], |
39
|
|
|
'password' => ['required', 'string', 'min:8', 'different:old_password', 'confirmed'], |
40
|
|
|
]; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Set custom messages for validator errors. |
45
|
|
|
* |
46
|
|
|
* @return array |
47
|
|
|
*/ |
48
|
|
|
public function messages() |
49
|
|
|
{ |
50
|
|
|
return [ |
51
|
|
|
'old_password.different' => trans('auth::profile.validation.password_different'), |
52
|
|
|
'password.different' => trans('auth::profile.validation.password_different'), |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/* ----------------------------------------------------------------- |
57
|
|
|
| Other Methods |
58
|
|
|
| ----------------------------------------------------------------- |
59
|
|
|
*/ |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the validated data. |
63
|
|
|
* |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
|
|
public function getValidatedData() |
67
|
|
|
{ |
68
|
|
|
return $this->only(['password']); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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: