1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* NOTICE OF LICENSE |
5
|
|
|
* |
6
|
|
|
* Part of the Rinvex Fort Package. |
7
|
|
|
* |
8
|
|
|
* This source file is subject to The MIT License (MIT) |
9
|
|
|
* that is bundled with this package in the LICENSE file. |
10
|
|
|
* |
11
|
|
|
* Package: Rinvex Fort Package |
12
|
|
|
* License: The MIT License (MIT) |
13
|
|
|
* Link: https://rinvex.com |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Rinvex\Fort\Models; |
17
|
|
|
|
18
|
|
|
use Rinvex\Fort\Traits\CanVerifyEmail; |
19
|
|
|
use Rinvex\Fort\Traits\Authenticatable; |
20
|
|
|
use Illuminate\Database\Eloquent\Model; |
21
|
|
|
use Illuminate\Notifications\Notifiable; |
22
|
|
|
use Rinvex\Fort\Traits\CanResetPassword; |
23
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes; |
24
|
|
|
use Rinvex\Fort\Contracts\CanVerifyEmailContract; |
25
|
|
|
use Rinvex\Fort\Contracts\AuthenticatableContract; |
26
|
|
|
use Illuminate\Foundation\Auth\Access\Authorizable; |
27
|
|
|
use Rinvex\Fort\Contracts\CanResetPasswordContract; |
28
|
|
|
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract; |
29
|
|
|
|
30
|
|
|
class User extends Model implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract, CanVerifyEmailContract |
|
|
|
|
31
|
|
|
{ |
32
|
|
|
use Notifiable, Authenticatable, Authorizable, CanResetPassword, CanVerifyEmail, SoftDeletes; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* {@inheritdoc} |
36
|
|
|
*/ |
37
|
|
|
protected $dates = [ |
38
|
|
|
'email_verified_at', |
39
|
|
|
'deleted_at', |
40
|
|
|
'birthdate', |
41
|
|
|
'login_at', |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritdoc} |
46
|
|
|
*/ |
47
|
|
|
protected $fillable = [ |
48
|
|
|
'username', |
49
|
|
|
'password', |
50
|
|
|
'two_factor', |
51
|
|
|
'email', |
52
|
|
|
'email_verified', |
53
|
|
|
'email_verified_at', |
54
|
|
|
'phone', |
55
|
|
|
'phone_verified', |
56
|
|
|
'phone_verified_at', |
57
|
|
|
'prefix', |
58
|
|
|
'first_name', |
59
|
|
|
'middle_name', |
60
|
|
|
'last_name', |
61
|
|
|
'sufix', |
62
|
|
|
'job_title', |
63
|
|
|
'country', |
64
|
|
|
'birthdate', |
65
|
|
|
'gender', |
66
|
|
|
'moderated', |
67
|
|
|
'login_at', |
68
|
|
|
]; |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* {@inheritdoc} |
72
|
|
|
*/ |
73
|
|
|
protected $hidden = [ |
74
|
|
|
'password', |
75
|
|
|
'two_factor', |
76
|
|
|
'remember_token', |
77
|
|
|
]; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Create a new Eloquent model instance. |
81
|
|
|
* |
82
|
|
|
* @param array $attributes |
83
|
|
|
* |
84
|
|
|
* @return void |
|
|
|
|
85
|
|
|
*/ |
86
|
|
|
public function __construct(array $attributes = []) |
87
|
|
|
{ |
88
|
|
|
parent::__construct($attributes); |
89
|
|
|
|
90
|
|
|
$this->setTable(config('rinvex.fort.tables.users')); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* A user may have multiple direct abilities. |
95
|
|
|
* |
96
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
97
|
|
|
*/ |
98
|
|
|
public function abilities() |
99
|
|
|
{ |
100
|
|
|
return $this->belongsToMany(config('rinvex.fort.models.ability'), config('rinvex.fort.tables.ability_user')) |
101
|
|
|
->withTimestamps(); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* A user may have multiple roles. |
106
|
|
|
* |
107
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
108
|
|
|
*/ |
109
|
|
|
public function roles() |
110
|
|
|
{ |
111
|
|
|
return $this->belongsToMany(config('rinvex.fort.models.role'), config('rinvex.fort.tables.role_user')) |
112
|
|
|
->withTimestamps(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* A user may have multiple persistences. |
117
|
|
|
* |
118
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
119
|
|
|
*/ |
120
|
|
|
public function persistences() |
121
|
|
|
{ |
122
|
|
|
return $this->hasMany(config('rinvex.fort.models.persistence')); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* A user may have multiple socialites. |
127
|
|
|
* |
128
|
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany |
129
|
|
|
*/ |
130
|
|
|
public function socialites() |
131
|
|
|
{ |
132
|
|
|
return $this->hasMany(config('rinvex.fort.models.socialite')); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.