|
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
|
|
|
|