|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace MrShan0\WordpressAuth\Models; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Database\Eloquent\Model; |
|
6
|
|
|
use Illuminate\Foundation\Auth\User as Authenticatable; |
|
7
|
|
|
use Illuminate\Notifications\Notifiable; |
|
8
|
|
|
use Illuminate\Support\Str; |
|
9
|
|
|
|
|
10
|
|
|
class WordpressUser extends Authenticatable |
|
11
|
|
|
{ |
|
12
|
|
|
use Notifiable; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Explicitly define your table name |
|
16
|
|
|
* |
|
17
|
|
|
* @var string |
|
18
|
|
|
*/ |
|
19
|
|
|
protected $table = 'users'; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Disable timestamps |
|
23
|
|
|
* |
|
24
|
|
|
* @var boolean |
|
25
|
|
|
*/ |
|
26
|
|
|
public $timestamps = false; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Define primary key |
|
30
|
|
|
* |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $primaryKey = 'ID'; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* The column name of the "remember me" token. |
|
37
|
|
|
* |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
protected $rememberTokenName = false; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* The attributes that should be mutated to dates. |
|
44
|
|
|
* |
|
45
|
|
|
* @var array |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $dates = [ |
|
48
|
|
|
'user_registered', |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* The attributes that should be hidden for arrays. |
|
53
|
|
|
* |
|
54
|
|
|
* @var array |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $hidden = [ |
|
57
|
|
|
'user_pass', |
|
58
|
|
|
'remember_token', // disabled via protected property |
|
59
|
|
|
]; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* The attributes that are mass assignable. |
|
63
|
|
|
* |
|
64
|
|
|
* @var array |
|
65
|
|
|
*/ |
|
66
|
|
|
protected $fillable = [ |
|
67
|
|
|
'user_login', |
|
68
|
|
|
'user_pass', |
|
69
|
|
|
'user_nicename', |
|
70
|
|
|
'user_email', |
|
71
|
|
|
'user_url', |
|
72
|
|
|
'user_registered', |
|
73
|
|
|
'user_activation_key', |
|
74
|
|
|
'user_status', |
|
75
|
|
|
'display_name', |
|
76
|
|
|
]; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Create a new Eloquent model instance. |
|
80
|
|
|
* |
|
81
|
|
|
* @param array $attributes |
|
82
|
|
|
* @return void |
|
83
|
|
|
*/ |
|
84
|
|
|
public function __construct(array $attributes = []) |
|
85
|
|
|
{ |
|
86
|
|
|
parent::__construct($attributes); |
|
87
|
|
|
|
|
88
|
|
|
// Set connection from config |
|
89
|
|
|
$this->setConnection(config('wordpress-auth.connection', 'mysql')); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get the e-mail address where password reset links are sent. |
|
94
|
|
|
* |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getEmailForPasswordReset() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->user_email; |
|
|
|
|
|
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* Return password value |
|
104
|
|
|
* |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
|
|
public function getAuthPassword() |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->user_pass; |
|
|
|
|
|
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Usage for notifiable for email |
|
114
|
|
|
* |
|
115
|
|
|
* @return string |
|
116
|
|
|
*/ |
|
117
|
|
|
public function routeNotificationForMail() |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->getEmailForPasswordReset(); |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
|