1 | <?php |
||
43 | abstract class User extends Model implements AuthenticatableContract, AuthenticatableTwoFactorContract, AuthorizableContract, CanResetPasswordContract, CanVerifyEmailContract, CanVerifyPhoneContract, HasMedia |
||
|
|||
44 | { |
||
45 | // @TODO: Strangely, this issue happens only here!!! |
||
46 | // Duplicate trait usage to fire attached events for cache |
||
47 | // flush before other events in other traits specially CausesActivity, |
||
48 | // otherwise old cached queries used and no changelog recorded on update. |
||
49 | use CacheableEloquent; |
||
50 | use Taggable; |
||
51 | use Auditable; |
||
52 | use Macroable { |
||
53 | Macroable::__call as macroableCall; |
||
54 | Macroable::__callStatic as macroableCallStatic; |
||
55 | } |
||
56 | use Notifiable; |
||
57 | use HashidsTrait; |
||
58 | use Authorizable; |
||
59 | use HasHashables; |
||
60 | use LogsActivity; |
||
61 | use HasMediaTrait; |
||
62 | use CanVerifyEmail; |
||
63 | use CausesActivity; |
||
64 | use CanVerifyPhone; |
||
65 | use Authenticatable; |
||
66 | use ValidatingTrait; |
||
67 | use CanResetPassword; |
||
68 | use HasSocialAttributes; |
||
69 | use HasRolesAndAbilities; |
||
70 | use AuthenticatableTwoFactor; |
||
71 | |||
72 | /** |
||
73 | * {@inheritdoc} |
||
74 | */ |
||
75 | protected $fillable = [ |
||
76 | 'username', |
||
77 | 'password', |
||
78 | 'two_factor', |
||
79 | 'email', |
||
80 | 'email_verified_at', |
||
81 | 'phone', |
||
82 | 'phone_verified_at', |
||
83 | 'given_name', |
||
84 | 'family_name', |
||
85 | 'title', |
||
86 | 'organization', |
||
87 | 'country_code', |
||
88 | 'language_code', |
||
89 | 'birthday', |
||
90 | 'gender', |
||
91 | 'social', |
||
92 | 'is_active', |
||
93 | 'last_activity', |
||
94 | 'abilities', |
||
95 | 'roles', |
||
96 | 'tags', |
||
97 | ]; |
||
98 | |||
99 | /** |
||
100 | * {@inheritdoc} |
||
101 | */ |
||
102 | protected $casts = [ |
||
103 | 'username' => 'string', |
||
104 | 'password' => 'string', |
||
105 | 'two_factor' => 'array', |
||
106 | 'email' => 'string', |
||
107 | 'email_verified_at' => 'datetime', |
||
108 | 'phone' => 'string', |
||
109 | 'phone_verified_at' => 'datetime', |
||
110 | 'given_name' => 'string', |
||
111 | 'family_name' => 'string', |
||
112 | 'title' => 'string', |
||
113 | 'organization' => 'string', |
||
114 | 'country_code' => 'string', |
||
115 | 'language_code' => 'string', |
||
116 | 'birthday' => 'string', |
||
117 | 'gender' => 'string', |
||
118 | 'social' => 'array', |
||
119 | 'is_active' => 'boolean', |
||
120 | 'last_activity' => 'datetime', |
||
121 | 'deleted_at' => 'datetime', |
||
122 | ]; |
||
123 | |||
124 | /** |
||
125 | * {@inheritdoc} |
||
126 | */ |
||
127 | protected $hidden = [ |
||
128 | 'password', |
||
129 | 'two_factor', |
||
130 | 'remember_token', |
||
131 | ]; |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | protected $observables = [ |
||
137 | 'validating', |
||
138 | 'validated', |
||
139 | ]; |
||
140 | |||
141 | /** |
||
142 | * The attributes to be encrypted before saving. |
||
143 | * |
||
144 | * @var array |
||
145 | */ |
||
146 | protected $hashables = [ |
||
147 | 'password', |
||
148 | ]; |
||
149 | |||
150 | /** |
||
151 | * The default rules that the model will validate against. |
||
152 | * |
||
153 | * @var array |
||
154 | */ |
||
155 | protected $rules = []; |
||
156 | |||
157 | /** |
||
158 | * Whether the model should throw a |
||
159 | * ValidationException if it fails validation. |
||
160 | * |
||
161 | * @var bool |
||
162 | */ |
||
163 | protected $throwValidationExceptions = true; |
||
164 | |||
165 | /** |
||
166 | * Indicates whether to log only dirty attributes or all. |
||
167 | * |
||
168 | * @var bool |
||
169 | */ |
||
170 | protected static $logOnlyDirty = true; |
||
171 | |||
172 | /** |
||
173 | * The attributes that are logged on change. |
||
174 | * |
||
175 | * @var array |
||
176 | */ |
||
177 | protected static $logFillable = true; |
||
178 | |||
179 | /** |
||
180 | * The attributes that are ignored on change. |
||
181 | * |
||
182 | * @var array |
||
183 | */ |
||
184 | protected static $ignoreChangedAttributes = [ |
||
185 | 'password', |
||
186 | 'two_factor', |
||
187 | 'email_verified_at', |
||
188 | 'phone_verified_at', |
||
189 | 'last_activity', |
||
190 | 'created_at', |
||
191 | 'updated_at', |
||
192 | 'deleted_at', |
||
193 | ]; |
||
194 | |||
195 | /** |
||
196 | * Register media collections. |
||
197 | * |
||
198 | * @return void |
||
199 | */ |
||
200 | public function registerMediaCollections(): void |
||
205 | |||
206 | /** |
||
207 | * Attach the given abilities to the model. |
||
208 | * |
||
209 | * @param mixed $abilities |
||
210 | * |
||
211 | * @return void |
||
212 | */ |
||
213 | public function setAbilitiesAttribute($abilities): void |
||
227 | |||
228 | /** |
||
229 | * Attach the given roles to the model. |
||
230 | * |
||
231 | * @param mixed $roles |
||
232 | * |
||
233 | * @return void |
||
234 | */ |
||
235 | public function setRolesAttribute($roles): void |
||
249 | |||
250 | /** |
||
251 | * {@inheritdoc} |
||
252 | */ |
||
253 | protected static function boot() |
||
265 | |||
266 | /** |
||
267 | * The user may have many sessions. |
||
268 | * |
||
269 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
270 | */ |
||
271 | public function sessions(): MorphMany |
||
275 | |||
276 | /** |
||
277 | * The user may have many socialites. |
||
278 | * |
||
279 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
280 | */ |
||
281 | public function socialites(): MorphMany |
||
285 | |||
286 | /** |
||
287 | * Route notifications for the authy channel. |
||
288 | * |
||
289 | * @return int|null |
||
290 | */ |
||
291 | public function routeNotificationForAuthy(): ?int |
||
308 | |||
309 | /** |
||
310 | * Get the user's country. |
||
311 | * |
||
312 | * @return \Rinvex\Country\Country |
||
313 | */ |
||
314 | public function getCountryAttribute(): Country |
||
318 | |||
319 | /** |
||
320 | * Get the user's language. |
||
321 | * |
||
322 | * @return \Rinvex\Language\Language |
||
323 | */ |
||
324 | public function getLanguageAttribute(): Language |
||
328 | |||
329 | /** |
||
330 | * Get full name attribute. |
||
331 | * |
||
332 | * @return string |
||
333 | */ |
||
334 | public function getFullNameAttribute(): string |
||
338 | |||
339 | /** |
||
340 | * Activate the user. |
||
341 | * |
||
342 | * @return $this |
||
343 | */ |
||
344 | public function activate() |
||
350 | |||
351 | /** |
||
352 | * Deactivate the user. |
||
353 | * |
||
354 | * @return $this |
||
355 | */ |
||
356 | public function deactivate() |
||
362 | |||
363 | /** |
||
364 | * Get managed roles. |
||
365 | * |
||
366 | * @return \Illuminate\Support\Collection |
||
367 | */ |
||
368 | public function getManagedRoles(): Collection |
||
380 | |||
381 | /** |
||
382 | * Get managed abilites. |
||
383 | * |
||
384 | * @return \Illuminate\Support\Collection |
||
385 | */ |
||
386 | public function getManagedAbilities(): Collection |
||
392 | |||
393 | /** |
||
394 | * Get the route key for the model. |
||
395 | * |
||
396 | * @return string |
||
397 | */ |
||
398 | public function getRouteKeyName() |
||
402 | |||
403 | /** |
||
404 | * Handle dynamic method calls into the model. |
||
405 | * |
||
406 | * @param string $method |
||
407 | * @param array $parameters |
||
408 | * |
||
409 | * @return mixed |
||
410 | */ |
||
411 | public function __call($method, $parameters) |
||
425 | |||
426 | /** |
||
427 | * Handle dynamic static method calls into the method. |
||
428 | * |
||
429 | * @param string $method |
||
430 | * @param array $parameters |
||
431 | * |
||
432 | * @return mixed |
||
433 | */ |
||
434 | public static function __callStatic($method, $parameters) |
||
444 | } |
||
445 |
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.