1 | <?php |
||
38 | abstract class User extends Model implements AuthenticatableContract, AuthenticatableTwoFactorContract, AuthorizableContract, CanResetPasswordContract, CanVerifyEmailContract, CanVerifyPhoneContract, HasMedia |
||
|
|||
39 | { |
||
40 | // @TODO: Strangely, this issue happens only here!!! |
||
41 | // Duplicate trait usage to fire attached events for cache |
||
42 | // flush before other events in other traits specially HasActivity, |
||
43 | // otherwise old cached queries used and no changelog recorded on update. |
||
44 | use CacheableEloquent; |
||
45 | use Taggable; |
||
46 | use Auditable; |
||
47 | use Notifiable; |
||
48 | use HasActivity; |
||
49 | use HashidsTrait; |
||
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 HasSocialAttributes; |
||
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 | 'given_name', |
||
77 | 'family_name', |
||
78 | 'title', |
||
79 | 'organization', |
||
80 | 'country_code', |
||
81 | 'language_code', |
||
82 | 'birthday', |
||
83 | 'gender', |
||
84 | 'social', |
||
85 | 'is_active', |
||
86 | 'last_activity', |
||
87 | 'abilities', |
||
88 | 'roles', |
||
89 | 'tags', |
||
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 | 'given_name' => 'string', |
||
106 | 'family_name' => 'string', |
||
107 | 'title' => 'string', |
||
108 | 'organization' => 'string', |
||
109 | 'country_code' => 'string', |
||
110 | 'language_code' => 'string', |
||
111 | 'birthday' => 'string', |
||
112 | 'gender' => 'string', |
||
113 | 'social' => 'array', |
||
114 | 'is_active' => 'boolean', |
||
115 | 'last_activity' => 'datetime', |
||
116 | 'deleted_at' => 'datetime', |
||
117 | ]; |
||
118 | |||
119 | /** |
||
120 | * {@inheritdoc} |
||
121 | */ |
||
122 | protected $hidden = [ |
||
123 | 'password', |
||
124 | 'two_factor', |
||
125 | 'remember_token', |
||
126 | ]; |
||
127 | |||
128 | /** |
||
129 | * {@inheritdoc} |
||
130 | */ |
||
131 | protected $observables = [ |
||
132 | 'validating', |
||
133 | 'validated', |
||
134 | ]; |
||
135 | |||
136 | /** |
||
137 | * The attributes to be encrypted before saving. |
||
138 | * |
||
139 | * @var array |
||
140 | */ |
||
141 | protected $hashables = [ |
||
142 | 'password', |
||
143 | ]; |
||
144 | |||
145 | /** |
||
146 | * The default rules that the model will validate against. |
||
147 | * |
||
148 | * @var array |
||
149 | */ |
||
150 | protected $rules = []; |
||
151 | |||
152 | /** |
||
153 | * Whether the model should throw a |
||
154 | * ValidationException if it fails validation. |
||
155 | * |
||
156 | * @var bool |
||
157 | */ |
||
158 | protected $throwValidationExceptions = true; |
||
159 | |||
160 | /** |
||
161 | * Indicates whether to log only dirty attributes or all. |
||
162 | * |
||
163 | * @var bool |
||
164 | */ |
||
165 | protected static $logOnlyDirty = true; |
||
166 | |||
167 | /** |
||
168 | * The attributes that are logged on change. |
||
169 | * |
||
170 | * @var array |
||
171 | */ |
||
172 | protected static $logFillable = true; |
||
173 | |||
174 | /** |
||
175 | * The attributes that are ignored on change. |
||
176 | * |
||
177 | * @var array |
||
178 | */ |
||
179 | protected static $ignoreChangedAttributes = [ |
||
180 | 'password', |
||
181 | 'two_factor', |
||
182 | 'email_verified_at', |
||
183 | 'phone_verified_at', |
||
184 | 'last_activity', |
||
185 | 'created_at', |
||
186 | 'updated_at', |
||
187 | 'deleted_at', |
||
188 | ]; |
||
189 | |||
190 | /** |
||
191 | * Register media collections. |
||
192 | * |
||
193 | * @return void |
||
194 | */ |
||
195 | public function registerMediaCollections(): void |
||
200 | |||
201 | /** |
||
202 | * Attach the given abilities to the model. |
||
203 | * |
||
204 | * @param mixed $abilities |
||
205 | * |
||
206 | * @return void |
||
207 | */ |
||
208 | public function setAbilitiesAttribute($abilities): void |
||
222 | |||
223 | /** |
||
224 | * Attach the given roles to the model. |
||
225 | * |
||
226 | * @param mixed $roles |
||
227 | * |
||
228 | * @return void |
||
229 | */ |
||
230 | public function setRolesAttribute($roles): void |
||
244 | |||
245 | /** |
||
246 | * {@inheritdoc} |
||
247 | */ |
||
248 | protected static function boot() |
||
260 | |||
261 | /** |
||
262 | * The user may have many sessions. |
||
263 | * |
||
264 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
265 | */ |
||
266 | public function sessions(): MorphMany |
||
270 | |||
271 | /** |
||
272 | * The user may have many socialites. |
||
273 | * |
||
274 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
275 | */ |
||
276 | public function socialites(): MorphMany |
||
280 | |||
281 | /** |
||
282 | * Route notifications for the authy channel. |
||
283 | * |
||
284 | * @return int|null |
||
285 | */ |
||
286 | public function routeNotificationForAuthy(): ?int |
||
303 | |||
304 | /** |
||
305 | * Get the user's country. |
||
306 | * |
||
307 | * @return \Rinvex\Country\Country |
||
308 | */ |
||
309 | public function getCountryAttribute(): Country |
||
313 | |||
314 | /** |
||
315 | * Get the user's language. |
||
316 | * |
||
317 | * @return \Rinvex\Language\Language |
||
318 | */ |
||
319 | public function getLanguageAttribute(): Language |
||
323 | |||
324 | /** |
||
325 | * Get full name attribute. |
||
326 | * |
||
327 | * @return string |
||
328 | */ |
||
329 | public function getFullNameAttribute(): string |
||
333 | |||
334 | /** |
||
335 | * Activate the user. |
||
336 | * |
||
337 | * @return $this |
||
338 | */ |
||
339 | public function makeActive() |
||
345 | |||
346 | /** |
||
347 | * Deactivate the user. |
||
348 | * |
||
349 | * @return $this |
||
350 | */ |
||
351 | public function makeInactive() |
||
357 | |||
358 | /** |
||
359 | * Get the route key for the model. |
||
360 | * |
||
361 | * @return string |
||
362 | */ |
||
363 | public function getRouteKeyName() |
||
367 | } |
||
368 |
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.