1 | <?php |
||
39 | class User extends Model implements AuthenticatableContract, AuthenticatableTwoFactorContract, AuthorizableContract, CanResetPasswordContract, CanVerifyEmailContract, CanVerifyPhoneContract, HasMedia |
||
|
|||
40 | { |
||
41 | // @TODO: Strangely, this issue happens only here!!! |
||
42 | // Duplicate trait usage to fire attached events for cache |
||
43 | // flush before other events in other traits specially LogsActivity, |
||
44 | // otherwise old cached queries used and no changelog recorded on update. |
||
45 | use CacheableEloquent; |
||
46 | use Auditable; |
||
47 | use Tenantable; |
||
48 | use Notifiable; |
||
49 | use HasActivity; |
||
50 | use Attributable; |
||
51 | use Authorizable; |
||
52 | use HasHashables; |
||
53 | use HasMediaTrait; |
||
54 | use CanVerifyEmail; |
||
55 | use CanVerifyPhone; |
||
56 | use Authenticatable; |
||
57 | use ValidatingTrait; |
||
58 | use CanResetPassword; |
||
59 | use CacheableEloquent; |
||
60 | use HasRolesAndAbilities; |
||
61 | use AuthenticatableTwoFactor; |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | protected $fillable = [ |
||
67 | 'username', |
||
68 | 'password', |
||
69 | 'two_factor', |
||
70 | 'email', |
||
71 | 'email_verified', |
||
72 | 'email_verified_at', |
||
73 | 'phone', |
||
74 | 'phone_verified', |
||
75 | 'phone_verified_at', |
||
76 | 'name_prefix', |
||
77 | 'first_name', |
||
78 | 'middle_name', |
||
79 | 'last_name', |
||
80 | 'name_suffix', |
||
81 | 'title', |
||
82 | 'country_code', |
||
83 | 'language_code', |
||
84 | 'birthday', |
||
85 | 'gender', |
||
86 | 'is_active', |
||
87 | 'last_activity', |
||
88 | 'abilities', |
||
89 | 'roles', |
||
90 | ]; |
||
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | protected $casts = [ |
||
96 | 'username' => 'string', |
||
97 | 'password' => 'string', |
||
98 | 'two_factor' => 'json', |
||
99 | 'email' => 'string', |
||
100 | 'email_verified' => 'boolean', |
||
101 | 'email_verified_at' => 'datetime', |
||
102 | 'phone' => 'string', |
||
103 | 'phone_verified' => 'boolean', |
||
104 | 'phone_verified_at' => 'datetime', |
||
105 | 'name_prefix' => 'string', |
||
106 | 'first_name' => 'string', |
||
107 | 'middle_name' => 'string', |
||
108 | 'last_name' => 'string', |
||
109 | 'name_suffix' => 'string', |
||
110 | 'title' => 'string', |
||
111 | 'country_code' => 'string', |
||
112 | 'language_code' => 'string', |
||
113 | 'birthday' => 'string', |
||
114 | 'gender' => 'string', |
||
115 | 'is_active' => 'boolean', |
||
116 | 'last_activity' => 'datetime', |
||
117 | 'deleted_at' => 'datetime', |
||
118 | ]; |
||
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | protected $hidden = [ |
||
124 | 'password', |
||
125 | 'two_factor', |
||
126 | 'remember_token', |
||
127 | ]; |
||
128 | |||
129 | /** |
||
130 | * {@inheritdoc} |
||
131 | */ |
||
132 | protected $observables = [ |
||
133 | 'validating', |
||
134 | 'validated', |
||
135 | ]; |
||
136 | |||
137 | /** |
||
138 | * The attributes to be encrypted before saving. |
||
139 | * |
||
140 | * @var array |
||
141 | */ |
||
142 | protected $hashables = [ |
||
143 | 'password', |
||
144 | ]; |
||
145 | |||
146 | /** |
||
147 | * The default rules that the model will validate against. |
||
148 | * |
||
149 | * @var array |
||
150 | */ |
||
151 | protected $rules = []; |
||
152 | |||
153 | /** |
||
154 | * Whether the model should throw a |
||
155 | * ValidationException if it fails validation. |
||
156 | * |
||
157 | * @var bool |
||
158 | */ |
||
159 | protected $throwValidationExceptions = true; |
||
160 | |||
161 | /** |
||
162 | * Indicates whether to log only dirty attributes or all. |
||
163 | * |
||
164 | * @var bool |
||
165 | */ |
||
166 | protected static $logOnlyDirty = true; |
||
167 | |||
168 | /** |
||
169 | * The attributes that are logged on change. |
||
170 | * |
||
171 | * @var array |
||
172 | */ |
||
173 | protected static $logFillable = true; |
||
174 | |||
175 | /** |
||
176 | * The attributes that are ignored on change. |
||
177 | * |
||
178 | * @var array |
||
179 | */ |
||
180 | protected static $ignoreChangedAttributes = [ |
||
181 | 'password', |
||
182 | 'two_factor', |
||
183 | 'email_verified_at', |
||
184 | 'phone_verified_at', |
||
185 | 'last_activity', |
||
186 | 'created_at', |
||
187 | 'updated_at', |
||
188 | 'deleted_at', |
||
189 | ]; |
||
190 | |||
191 | /** |
||
192 | * {@inheritdoc} |
||
193 | */ |
||
194 | protected $passwordResetNotificationClass = PasswordResetNotification::class; |
||
195 | |||
196 | /** |
||
197 | * {@inheritdoc} |
||
198 | */ |
||
199 | protected $emailVerificationNotificationClass = EmailVerificationNotification::class; |
||
200 | |||
201 | /** |
||
202 | * {@inheritdoc} |
||
203 | */ |
||
204 | protected $phoneVerificationNotificationClass = PhoneVerificationNotification::class; |
||
205 | |||
206 | /** |
||
207 | * Get the route key for the model. |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | public function getRouteKeyName(): string |
||
215 | |||
216 | /** |
||
217 | * Register media collections. |
||
218 | * |
||
219 | * @return void |
||
220 | */ |
||
221 | public function registerMediaCollections(): void |
||
226 | |||
227 | /** |
||
228 | * Attach the given abilities to the model. |
||
229 | * |
||
230 | * @param mixed $abilities |
||
231 | * |
||
232 | * @return void |
||
233 | */ |
||
234 | public function setAbilitiesAttribute($abilities): void |
||
245 | |||
246 | /** |
||
247 | * Attach the given roles to the model. |
||
248 | * |
||
249 | * @param mixed $roles |
||
250 | * |
||
251 | * @return void |
||
252 | */ |
||
253 | public function setRolesAttribute($roles): void |
||
264 | |||
265 | /** |
||
266 | * Create a new Eloquent model instance. |
||
267 | * |
||
268 | * @param array $attributes |
||
269 | */ |
||
270 | public function __construct(array $attributes = []) |
||
299 | |||
300 | /** |
||
301 | * {@inheritdoc} |
||
302 | */ |
||
303 | protected static function boot() |
||
315 | |||
316 | /** |
||
317 | * The user may have many sessions. |
||
318 | * |
||
319 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
320 | */ |
||
321 | public function sessions(): MorphMany |
||
325 | |||
326 | /** |
||
327 | * The user may have many socialites. |
||
328 | * |
||
329 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
330 | */ |
||
331 | public function socialites(): MorphMany |
||
335 | |||
336 | /** |
||
337 | * Get name attribute. |
||
338 | * |
||
339 | * @return string |
||
340 | */ |
||
341 | public function getNameAttribute(): string |
||
347 | |||
348 | /** |
||
349 | * Route notifications for the authy channel. |
||
350 | * |
||
351 | * @return int|null |
||
352 | */ |
||
353 | public function routeNotificationForAuthy(): ?int |
||
370 | |||
371 | /** |
||
372 | * Get the user's country. |
||
373 | * |
||
374 | * @return \Rinvex\Country\Country |
||
375 | */ |
||
376 | public function getCountryAttribute(): Country |
||
380 | |||
381 | /** |
||
382 | * Get the user's language. |
||
383 | * |
||
384 | * @return \Rinvex\Language\Language |
||
385 | */ |
||
386 | public function getLanguageAttribute(): Language |
||
390 | |||
391 | /** |
||
392 | * Activate the user. |
||
393 | * |
||
394 | * @return $this |
||
395 | */ |
||
396 | public function activate() |
||
402 | |||
403 | /** |
||
404 | * Deactivate the user. |
||
405 | * |
||
406 | * @return $this |
||
407 | */ |
||
408 | public function deactivate() |
||
414 | } |
||
415 |
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.