Completed
Push — master ( 3c59f9...34cc61 )
by ARCANEDEV
03:16
created

PasswordReset   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 4 1
A getTokenRepository() 0 4 1
A isExpired() 0 8 1
1
<?php namespace Arcanesoft\Auth\Models;
2
3
use Arcanedev\Support\Bases\Model;
4
use Carbon\Carbon;
5
6
/**
7
 * Class     PasswordReset
8
 *
9
 * @package  Arcanesoft\Auth\Models
10
 * @author   ARCANEDEV <[email protected]>
11
 *
12
 * @property  string                        email
13
 * @property  string                        token
14
 * @property  \Carbon\Carbon                created_at
15
 * @property  \Arcanesoft\Auth\Models\User  user
16
 */
17
class PasswordReset extends Model
18
{
19
    /* ------------------------------------------------------------------------------------------------
20
     |  Properties
21
     | ------------------------------------------------------------------------------------------------
22
     */
23
    protected $table   = 'password_resets';
24
25
    protected $hidden  = ['token'];
26
27
    public $timestamps = false;
28
29
    protected $dates   = [self::CREATED_AT];
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Relationships
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    public function user()
36
    {
37
        return $this->belongsTo(User::class, 'email', 'email');
38
    }
39
40
    /* ------------------------------------------------------------------------------------------------
41
     |  Getters & Setters
42
     | ------------------------------------------------------------------------------------------------
43
     */
44
    /**
45
     * Get the token repository.
46
     *
47
     * @return \Illuminate\Auth\Passwords\TokenRepositoryInterface
48
     */
49
    public static function getTokenRepository()
50
    {
51
        return app('auth.password')->getRepository();
52
    }
53
54
    /* ------------------------------------------------------------------------------------------------
55
     |  Check Functions
56
     | ------------------------------------------------------------------------------------------------
57
     */
58
    /**
59
     * Check if the password reset was expired.
60
     *
61
     * @return bool
62
     */
63
    public function isExpired()
64
    {
65
        $expiredAt = Carbon::now()->subMinutes(
66
            config('auth.passwords.users.expire', 60)
67
        );
68
69
        return $this->created_at->lt($expiredAt);
70
    }
71
}
72