1 | <?php |
||
37 | abstract class User extends Model implements AuthenticatableContract, AuthenticatableTwoFactorContract, AuthorizableContract, CanResetPasswordContract, CanVerifyEmailContract, CanVerifyPhoneContract, HasMedia |
||
|
|||
38 | { |
||
39 | // @TODO: Strangely, this issue happens only here!!! |
||
40 | // Duplicate trait usage to fire attached events for cache |
||
41 | // flush before other events in other traits specially HasActivity, |
||
42 | // otherwise old cached queries used and no changelog recorded on update. |
||
43 | use CacheableEloquent; |
||
44 | use Taggable; |
||
45 | use Auditable; |
||
46 | use Notifiable; |
||
47 | use HasActivity; |
||
48 | use Attributable; |
||
49 | use Authorizable; |
||
50 | use HasHashables; |
||
51 | use HasMediaTrait; |
||
52 | use CanVerifyEmail; |
||
53 | use CanVerifyPhone; |
||
54 | use Authenticatable; |
||
55 | use ValidatingTrait; |
||
56 | use CanResetPassword; |
||
57 | use HasRolesAndAbilities; |
||
58 | use AuthenticatableTwoFactor; |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | protected $fillable = [ |
||
64 | 'username', |
||
65 | 'password', |
||
66 | 'two_factor', |
||
67 | 'email', |
||
68 | 'email_verified', |
||
69 | 'email_verified_at', |
||
70 | 'phone', |
||
71 | 'phone_verified', |
||
72 | 'phone_verified_at', |
||
73 | 'full_name', |
||
74 | 'title', |
||
75 | 'country_code', |
||
76 | 'language_code', |
||
77 | 'birthday', |
||
78 | 'gender', |
||
79 | 'is_active', |
||
80 | 'last_activity', |
||
81 | 'abilities', |
||
82 | 'roles', |
||
83 | 'tags', |
||
84 | ]; |
||
85 | |||
86 | /** |
||
87 | * {@inheritdoc} |
||
88 | */ |
||
89 | protected $casts = [ |
||
90 | 'username' => 'string', |
||
91 | 'password' => 'string', |
||
92 | 'two_factor' => 'json', |
||
93 | 'email' => 'string', |
||
94 | 'email_verified' => 'boolean', |
||
95 | 'email_verified_at' => 'datetime', |
||
96 | 'phone' => 'string', |
||
97 | 'phone_verified' => 'boolean', |
||
98 | 'phone_verified_at' => 'datetime', |
||
99 | 'full_name' => 'string', |
||
100 | 'title' => 'string', |
||
101 | 'country_code' => 'string', |
||
102 | 'language_code' => 'string', |
||
103 | 'birthday' => 'string', |
||
104 | 'gender' => 'string', |
||
105 | 'is_active' => 'boolean', |
||
106 | 'last_activity' => 'datetime', |
||
107 | 'deleted_at' => 'datetime', |
||
108 | ]; |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | protected $hidden = [ |
||
114 | 'password', |
||
115 | 'two_factor', |
||
116 | 'remember_token', |
||
117 | ]; |
||
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | protected $observables = [ |
||
123 | 'validating', |
||
124 | 'validated', |
||
125 | ]; |
||
126 | |||
127 | /** |
||
128 | * The attributes to be encrypted before saving. |
||
129 | * |
||
130 | * @var array |
||
131 | */ |
||
132 | protected $hashables = [ |
||
133 | 'password', |
||
134 | ]; |
||
135 | |||
136 | /** |
||
137 | * The default rules that the model will validate against. |
||
138 | * |
||
139 | * @var array |
||
140 | */ |
||
141 | protected $rules = []; |
||
142 | |||
143 | /** |
||
144 | * Whether the model should throw a |
||
145 | * ValidationException if it fails validation. |
||
146 | * |
||
147 | * @var bool |
||
148 | */ |
||
149 | protected $throwValidationExceptions = true; |
||
150 | |||
151 | /** |
||
152 | * Indicates whether to log only dirty attributes or all. |
||
153 | * |
||
154 | * @var bool |
||
155 | */ |
||
156 | protected static $logOnlyDirty = true; |
||
157 | |||
158 | /** |
||
159 | * The attributes that are logged on change. |
||
160 | * |
||
161 | * @var array |
||
162 | */ |
||
163 | protected static $logFillable = true; |
||
164 | |||
165 | /** |
||
166 | * The attributes that are ignored on change. |
||
167 | * |
||
168 | * @var array |
||
169 | */ |
||
170 | protected static $ignoreChangedAttributes = [ |
||
171 | 'password', |
||
172 | 'two_factor', |
||
173 | 'email_verified_at', |
||
174 | 'phone_verified_at', |
||
175 | 'last_activity', |
||
176 | 'created_at', |
||
177 | 'updated_at', |
||
178 | 'deleted_at', |
||
179 | ]; |
||
180 | |||
181 | /** |
||
182 | * Get the value of the model's route key. |
||
183 | * |
||
184 | * @return mixed |
||
185 | */ |
||
186 | public function getRouteKey() |
||
190 | |||
191 | /** |
||
192 | * Retrieve the model for a bound value. |
||
193 | * |
||
194 | * @param mixed $value |
||
195 | * @return \Illuminate\Database\Eloquent\Model|null |
||
196 | */ |
||
197 | public function resolveRouteBinding($value) |
||
203 | |||
204 | /** |
||
205 | * Register media collections. |
||
206 | * |
||
207 | * @return void |
||
208 | */ |
||
209 | public function registerMediaCollections(): void |
||
214 | |||
215 | /** |
||
216 | * Attach the given abilities to the model. |
||
217 | * |
||
218 | * @param mixed $abilities |
||
219 | * |
||
220 | * @return void |
||
221 | */ |
||
222 | public function setAbilitiesAttribute($abilities): void |
||
236 | |||
237 | /** |
||
238 | * Attach the given roles to the model. |
||
239 | * |
||
240 | * @param mixed $roles |
||
241 | * |
||
242 | * @return void |
||
243 | */ |
||
244 | public function setRolesAttribute($roles): void |
||
258 | |||
259 | /** |
||
260 | * {@inheritdoc} |
||
261 | */ |
||
262 | protected static function boot() |
||
274 | |||
275 | /** |
||
276 | * The user may have many sessions. |
||
277 | * |
||
278 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
279 | */ |
||
280 | public function sessions(): MorphMany |
||
284 | |||
285 | /** |
||
286 | * The user may have many socialites. |
||
287 | * |
||
288 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
289 | */ |
||
290 | public function socialites(): MorphMany |
||
294 | |||
295 | /** |
||
296 | * Route notifications for the authy channel. |
||
297 | * |
||
298 | * @return int|null |
||
299 | */ |
||
300 | public function routeNotificationForAuthy(): ?int |
||
317 | |||
318 | /** |
||
319 | * Get the user's country. |
||
320 | * |
||
321 | * @return \Rinvex\Country\Country |
||
322 | */ |
||
323 | public function getCountryAttribute(): Country |
||
327 | |||
328 | /** |
||
329 | * Get the user's language. |
||
330 | * |
||
331 | * @return \Rinvex\Language\Language |
||
332 | */ |
||
333 | public function getLanguageAttribute(): Language |
||
337 | |||
338 | /** |
||
339 | * Activate the user. |
||
340 | * |
||
341 | * @return $this |
||
342 | */ |
||
343 | public function activate() |
||
349 | |||
350 | /** |
||
351 | * Deactivate the user. |
||
352 | * |
||
353 | * @return $this |
||
354 | */ |
||
355 | public function deactivate() |
||
361 | } |
||
362 |
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.