1 | <?php |
||
35 | abstract class User extends Model implements AuthenticatableContract, AuthenticatableTwoFactorContract, AuthorizableContract, CanResetPasswordContract, CanVerifyEmailContract, CanVerifyPhoneContract, HasMedia |
||
|
|||
36 | { |
||
37 | // @TODO: Strangely, this issue happens only here!!! |
||
38 | // Duplicate trait usage to fire attached events for cache |
||
39 | // flush before other events in other traits specially HasActivity, |
||
40 | // otherwise old cached queries used and no changelog recorded on update. |
||
41 | use CacheableEloquent; |
||
42 | use Auditable; |
||
43 | use Notifiable; |
||
44 | use HasActivity; |
||
45 | use Attributable; |
||
46 | use Authorizable; |
||
47 | use HasHashables; |
||
48 | use HasMediaTrait; |
||
49 | use CanVerifyEmail; |
||
50 | use CanVerifyPhone; |
||
51 | use Authenticatable; |
||
52 | use ValidatingTrait; |
||
53 | use CanResetPassword; |
||
54 | use HasRolesAndAbilities; |
||
55 | use AuthenticatableTwoFactor; |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | protected $fillable = [ |
||
61 | 'username', |
||
62 | 'password', |
||
63 | 'two_factor', |
||
64 | 'email', |
||
65 | 'email_verified', |
||
66 | 'email_verified_at', |
||
67 | 'phone', |
||
68 | 'phone_verified', |
||
69 | 'phone_verified_at', |
||
70 | 'full_name', |
||
71 | 'title', |
||
72 | 'country_code', |
||
73 | 'language_code', |
||
74 | 'birthday', |
||
75 | 'gender', |
||
76 | 'is_active', |
||
77 | 'last_activity', |
||
78 | 'abilities', |
||
79 | 'roles', |
||
80 | ]; |
||
81 | |||
82 | /** |
||
83 | * {@inheritdoc} |
||
84 | */ |
||
85 | protected $casts = [ |
||
86 | 'username' => 'string', |
||
87 | 'password' => 'string', |
||
88 | 'two_factor' => 'json', |
||
89 | 'email' => 'string', |
||
90 | 'email_verified' => 'boolean', |
||
91 | 'email_verified_at' => 'datetime', |
||
92 | 'phone' => 'string', |
||
93 | 'phone_verified' => 'boolean', |
||
94 | 'phone_verified_at' => 'datetime', |
||
95 | 'full_name' => 'string', |
||
96 | 'title' => 'string', |
||
97 | 'country_code' => 'string', |
||
98 | 'language_code' => 'string', |
||
99 | 'birthday' => 'string', |
||
100 | 'gender' => 'string', |
||
101 | 'is_active' => 'boolean', |
||
102 | 'last_activity' => 'datetime', |
||
103 | 'deleted_at' => 'datetime', |
||
104 | ]; |
||
105 | |||
106 | /** |
||
107 | * {@inheritdoc} |
||
108 | */ |
||
109 | protected $hidden = [ |
||
110 | 'password', |
||
111 | 'two_factor', |
||
112 | 'remember_token', |
||
113 | ]; |
||
114 | |||
115 | /** |
||
116 | * {@inheritdoc} |
||
117 | */ |
||
118 | protected $observables = [ |
||
119 | 'validating', |
||
120 | 'validated', |
||
121 | ]; |
||
122 | |||
123 | /** |
||
124 | * The attributes to be encrypted before saving. |
||
125 | * |
||
126 | * @var array |
||
127 | */ |
||
128 | protected $hashables = [ |
||
129 | 'password', |
||
130 | ]; |
||
131 | |||
132 | /** |
||
133 | * The default rules that the model will validate against. |
||
134 | * |
||
135 | * @var array |
||
136 | */ |
||
137 | protected $rules = []; |
||
138 | |||
139 | /** |
||
140 | * Whether the model should throw a |
||
141 | * ValidationException if it fails validation. |
||
142 | * |
||
143 | * @var bool |
||
144 | */ |
||
145 | protected $throwValidationExceptions = true; |
||
146 | |||
147 | /** |
||
148 | * Indicates whether to log only dirty attributes or all. |
||
149 | * |
||
150 | * @var bool |
||
151 | */ |
||
152 | protected static $logOnlyDirty = true; |
||
153 | |||
154 | /** |
||
155 | * The attributes that are logged on change. |
||
156 | * |
||
157 | * @var array |
||
158 | */ |
||
159 | protected static $logFillable = true; |
||
160 | |||
161 | /** |
||
162 | * The attributes that are ignored on change. |
||
163 | * |
||
164 | * @var array |
||
165 | */ |
||
166 | protected static $ignoreChangedAttributes = [ |
||
167 | 'password', |
||
168 | 'two_factor', |
||
169 | 'email_verified_at', |
||
170 | 'phone_verified_at', |
||
171 | 'last_activity', |
||
172 | 'created_at', |
||
173 | 'updated_at', |
||
174 | 'deleted_at', |
||
175 | ]; |
||
176 | |||
177 | /** |
||
178 | * Get the route key for the model. |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | public function getRouteKeyName(): string |
||
186 | |||
187 | /** |
||
188 | * Register media collections. |
||
189 | * |
||
190 | * @return void |
||
191 | */ |
||
192 | public function registerMediaCollections(): void |
||
197 | |||
198 | /** |
||
199 | * Attach the given abilities to the model. |
||
200 | * |
||
201 | * @param mixed $abilities |
||
202 | * |
||
203 | * @return void |
||
204 | */ |
||
205 | public function setAbilitiesAttribute($abilities): void |
||
219 | |||
220 | /** |
||
221 | * Attach the given roles to the model. |
||
222 | * |
||
223 | * @param mixed $roles |
||
224 | * |
||
225 | * @return void |
||
226 | */ |
||
227 | public function setRolesAttribute($roles): void |
||
241 | |||
242 | /** |
||
243 | * {@inheritdoc} |
||
244 | */ |
||
245 | protected static function boot() |
||
257 | |||
258 | /** |
||
259 | * The user may have many sessions. |
||
260 | * |
||
261 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
262 | */ |
||
263 | public function sessions(): MorphMany |
||
267 | |||
268 | /** |
||
269 | * The user may have many socialites. |
||
270 | * |
||
271 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
272 | */ |
||
273 | public function socialites(): MorphMany |
||
277 | |||
278 | /** |
||
279 | * Route notifications for the authy channel. |
||
280 | * |
||
281 | * @return int|null |
||
282 | */ |
||
283 | public function routeNotificationForAuthy(): ?int |
||
300 | |||
301 | /** |
||
302 | * Get the user's country. |
||
303 | * |
||
304 | * @return \Rinvex\Country\Country |
||
305 | */ |
||
306 | public function getCountryAttribute(): Country |
||
310 | |||
311 | /** |
||
312 | * Get the user's language. |
||
313 | * |
||
314 | * @return \Rinvex\Language\Language |
||
315 | */ |
||
316 | public function getLanguageAttribute(): Language |
||
320 | |||
321 | /** |
||
322 | * Activate the user. |
||
323 | * |
||
324 | * @return $this |
||
325 | */ |
||
326 | public function activate() |
||
332 | |||
333 | /** |
||
334 | * Deactivate the user. |
||
335 | * |
||
336 | * @return $this |
||
337 | */ |
||
338 | public function deactivate() |
||
344 | } |
||
345 |
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.