Completed
Push — master ( 720025...0e57e6 )
by ARCANEDEV
04:07
created

UpdatePasswordRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 55
c 0
b 0
f 0
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 6 1
A rules() 0 7 1
A messages() 0 7 1
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
     |  Properties
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Authenticated user.
19
     *
20
     * @var \Arcanesoft\Contracts\Auth\Models\User $user
21
     */
22
    protected $user;
23
24
    /* ------------------------------------------------------------------------------------------------
25
     |  Main Functions
26
     | ------------------------------------------------------------------------------------------------
27
     */
28
    /**
29
     * Determine if the user is authorized to make this request.
30
     *
31
     * @return bool
32
     */
33
    public function authorize()
34
    {
35
        $this->user = $this->route('auth_user');
36
37
        return $this->user->id === auth()->user()->id;
38
    }
39
40
    /**
41
     * Get the validation rules that apply to the request.
42
     *
43
     * @return array
44
     */
45
    public function rules()
46
    {
47
        return [
48
            'old_password' => 'required|min:8|different:password|user_password',
49
            'password'     => 'required|min:8|different:old_password|confirmed',
50
        ];
51
    }
52
53
    /**
54
     * Set custom messages for validator errors.
55
     *
56
     * @return array
57
     */
58
    public function messages()
59
    {
60
        return [
61
            'old_password.different' => 'The old and new passwords must be different.',
62
            'password.different'     => 'The old and new passwords must be different.',
63
        ];
64
    }
65
}
66