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