1 | <?php |
||
41 | abstract class User extends Model implements AuthenticatableContract, AuthenticatableTwoFactorContract, AuthorizableContract, CanResetPasswordContract, CanVerifyEmailContract, CanVerifyPhoneContract, HasMedia |
||
|
|||
42 | { |
||
43 | // @TODO: Strangely, this issue happens only here!!! |
||
44 | // Duplicate trait usage to fire attached events for cache |
||
45 | // flush before other events in other traits specially HasActivity, |
||
46 | // otherwise old cached queries used and no changelog recorded on update. |
||
47 | use CacheableEloquent; |
||
48 | use Taggable; |
||
49 | use Auditable; |
||
50 | use Macroable { |
||
51 | Macroable::__call as macroableCall; |
||
52 | Macroable::__callStatic as macroableCallStatic; |
||
53 | } |
||
54 | use Notifiable; |
||
55 | use HasActivity; |
||
56 | use HashidsTrait; |
||
57 | use Authorizable; |
||
58 | use HasHashables; |
||
59 | use HasMediaTrait; |
||
60 | use CanVerifyEmail; |
||
61 | use CanVerifyPhone; |
||
62 | use Authenticatable; |
||
63 | use ValidatingTrait; |
||
64 | use CanResetPassword; |
||
65 | use HasSocialAttributes; |
||
66 | use HasRolesAndAbilities; |
||
67 | use AuthenticatableTwoFactor; |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | */ |
||
72 | protected $fillable = [ |
||
73 | 'username', |
||
74 | 'password', |
||
75 | 'two_factor', |
||
76 | 'email', |
||
77 | 'email_verified_at', |
||
78 | 'phone', |
||
79 | 'phone_verified_at', |
||
80 | 'given_name', |
||
81 | 'family_name', |
||
82 | 'title', |
||
83 | 'organization', |
||
84 | 'country_code', |
||
85 | 'language_code', |
||
86 | 'birthday', |
||
87 | 'gender', |
||
88 | 'social', |
||
89 | 'is_active', |
||
90 | 'last_activity', |
||
91 | 'abilities', |
||
92 | 'roles', |
||
93 | 'tags', |
||
94 | ]; |
||
95 | |||
96 | /** |
||
97 | * {@inheritdoc} |
||
98 | */ |
||
99 | protected $casts = [ |
||
100 | 'username' => 'string', |
||
101 | 'password' => 'string', |
||
102 | 'two_factor' => 'json', |
||
103 | 'email' => 'string', |
||
104 | 'email_verified_at' => 'datetime', |
||
105 | 'phone' => 'string', |
||
106 | 'phone_verified_at' => 'datetime', |
||
107 | 'given_name' => 'string', |
||
108 | 'family_name' => 'string', |
||
109 | 'title' => 'string', |
||
110 | 'organization' => 'string', |
||
111 | 'country_code' => 'string', |
||
112 | 'language_code' => 'string', |
||
113 | 'birthday' => 'string', |
||
114 | 'gender' => 'string', |
||
115 | 'social' => 'array', |
||
116 | 'is_active' => 'boolean', |
||
117 | 'last_activity' => 'datetime', |
||
118 | 'deleted_at' => 'datetime', |
||
119 | ]; |
||
120 | |||
121 | /** |
||
122 | * {@inheritdoc} |
||
123 | */ |
||
124 | protected $hidden = [ |
||
125 | 'password', |
||
126 | 'two_factor', |
||
127 | 'remember_token', |
||
128 | ]; |
||
129 | |||
130 | /** |
||
131 | * {@inheritdoc} |
||
132 | */ |
||
133 | protected $observables = [ |
||
134 | 'validating', |
||
135 | 'validated', |
||
136 | ]; |
||
137 | |||
138 | /** |
||
139 | * The attributes to be encrypted before saving. |
||
140 | * |
||
141 | * @var array |
||
142 | */ |
||
143 | protected $hashables = [ |
||
144 | 'password', |
||
145 | ]; |
||
146 | |||
147 | /** |
||
148 | * The default rules that the model will validate against. |
||
149 | * |
||
150 | * @var array |
||
151 | */ |
||
152 | protected $rules = []; |
||
153 | |||
154 | /** |
||
155 | * Whether the model should throw a |
||
156 | * ValidationException if it fails validation. |
||
157 | * |
||
158 | * @var bool |
||
159 | */ |
||
160 | protected $throwValidationExceptions = true; |
||
161 | |||
162 | /** |
||
163 | * Indicates whether to log only dirty attributes or all. |
||
164 | * |
||
165 | * @var bool |
||
166 | */ |
||
167 | protected static $logOnlyDirty = true; |
||
168 | |||
169 | /** |
||
170 | * The attributes that are logged on change. |
||
171 | * |
||
172 | * @var array |
||
173 | */ |
||
174 | protected static $logFillable = true; |
||
175 | |||
176 | /** |
||
177 | * The attributes that are ignored on change. |
||
178 | * |
||
179 | * @var array |
||
180 | */ |
||
181 | protected static $ignoreChangedAttributes = [ |
||
182 | 'password', |
||
183 | 'two_factor', |
||
184 | 'email_verified_at', |
||
185 | 'phone_verified_at', |
||
186 | 'last_activity', |
||
187 | 'created_at', |
||
188 | 'updated_at', |
||
189 | 'deleted_at', |
||
190 | ]; |
||
191 | |||
192 | /** |
||
193 | * Register media collections. |
||
194 | * |
||
195 | * @return void |
||
196 | */ |
||
197 | public function registerMediaCollections(): void |
||
202 | |||
203 | /** |
||
204 | * Attach the given abilities to the model. |
||
205 | * |
||
206 | * @param mixed $abilities |
||
207 | * |
||
208 | * @return void |
||
209 | */ |
||
210 | public function setAbilitiesAttribute($abilities): void |
||
224 | |||
225 | /** |
||
226 | * Attach the given roles to the model. |
||
227 | * |
||
228 | * @param mixed $roles |
||
229 | * |
||
230 | * @return void |
||
231 | */ |
||
232 | public function setRolesAttribute($roles): void |
||
246 | |||
247 | /** |
||
248 | * {@inheritdoc} |
||
249 | */ |
||
250 | protected static function boot() |
||
262 | |||
263 | /** |
||
264 | * The user may have many sessions. |
||
265 | * |
||
266 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
267 | */ |
||
268 | public function sessions(): MorphMany |
||
272 | |||
273 | /** |
||
274 | * The user may have many socialites. |
||
275 | * |
||
276 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
277 | */ |
||
278 | public function socialites(): MorphMany |
||
282 | |||
283 | /** |
||
284 | * Route notifications for the authy channel. |
||
285 | * |
||
286 | * @return int|null |
||
287 | */ |
||
288 | public function routeNotificationForAuthy(): ?int |
||
305 | |||
306 | /** |
||
307 | * Get the user's country. |
||
308 | * |
||
309 | * @return \Rinvex\Country\Country |
||
310 | */ |
||
311 | public function getCountryAttribute(): Country |
||
315 | |||
316 | /** |
||
317 | * Get the user's language. |
||
318 | * |
||
319 | * @return \Rinvex\Language\Language |
||
320 | */ |
||
321 | public function getLanguageAttribute(): Language |
||
325 | |||
326 | /** |
||
327 | * Get full name attribute. |
||
328 | * |
||
329 | * @return string |
||
330 | */ |
||
331 | public function getFullNameAttribute(): string |
||
335 | |||
336 | /** |
||
337 | * Activate the user. |
||
338 | * |
||
339 | * @return $this |
||
340 | */ |
||
341 | public function activate() |
||
347 | |||
348 | /** |
||
349 | * Deactivate the user. |
||
350 | * |
||
351 | * @return $this |
||
352 | */ |
||
353 | public function deactivate() |
||
359 | |||
360 | /** |
||
361 | * Get the route key for the model. |
||
362 | * |
||
363 | * @return string |
||
364 | */ |
||
365 | public function getRouteKeyName() |
||
369 | |||
370 | /** |
||
371 | * Handle dynamic method calls into the model. |
||
372 | * |
||
373 | * @param string $method |
||
374 | * @param array $parameters |
||
375 | * @return mixed |
||
376 | */ |
||
377 | public function __call($method, $parameters) |
||
389 | |||
390 | /** |
||
391 | * Handle dynamic static method calls into the method. |
||
392 | * |
||
393 | * @param string $method |
||
394 | * @param array $parameters |
||
395 | * @return mixed |
||
396 | */ |
||
397 | public static function __callStatic($method, $parameters) |
||
405 | } |
||
406 |
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.