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 HashidsTrait; |
||
49 | use Attributable; |
||
50 | use Authorizable; |
||
51 | use HasHashables; |
||
52 | use HasMediaTrait; |
||
53 | use CanVerifyEmail; |
||
54 | use CanVerifyPhone; |
||
55 | use Authenticatable; |
||
56 | use ValidatingTrait; |
||
57 | use CanResetPassword; |
||
58 | use HasRolesAndAbilities; |
||
59 | use AuthenticatableTwoFactor; |
||
60 | |||
61 | /** |
||
62 | * {@inheritdoc} |
||
63 | */ |
||
64 | protected $fillable = [ |
||
65 | 'username', |
||
66 | 'password', |
||
67 | 'two_factor', |
||
68 | 'email', |
||
69 | 'email_verified', |
||
70 | 'email_verified_at', |
||
71 | 'phone', |
||
72 | 'phone_verified', |
||
73 | 'phone_verified_at', |
||
74 | 'full_name', |
||
75 | 'title', |
||
76 | 'country_code', |
||
77 | 'language_code', |
||
78 | 'birthday', |
||
79 | 'gender', |
||
80 | 'is_active', |
||
81 | 'last_activity', |
||
82 | 'abilities', |
||
83 | 'roles', |
||
84 | 'tags', |
||
85 | ]; |
||
86 | |||
87 | /** |
||
88 | * {@inheritdoc} |
||
89 | */ |
||
90 | protected $casts = [ |
||
91 | 'username' => 'string', |
||
92 | 'password' => 'string', |
||
93 | 'two_factor' => 'json', |
||
94 | 'email' => 'string', |
||
95 | 'email_verified' => 'boolean', |
||
96 | 'email_verified_at' => 'datetime', |
||
97 | 'phone' => 'string', |
||
98 | 'phone_verified' => 'boolean', |
||
99 | 'phone_verified_at' => 'datetime', |
||
100 | 'full_name' => 'string', |
||
101 | 'title' => 'string', |
||
102 | 'country_code' => 'string', |
||
103 | 'language_code' => 'string', |
||
104 | 'birthday' => 'string', |
||
105 | 'gender' => 'string', |
||
106 | 'is_active' => 'boolean', |
||
107 | 'last_activity' => 'datetime', |
||
108 | 'deleted_at' => 'datetime', |
||
109 | ]; |
||
110 | |||
111 | /** |
||
112 | * {@inheritdoc} |
||
113 | */ |
||
114 | protected $hidden = [ |
||
115 | 'password', |
||
116 | 'two_factor', |
||
117 | 'remember_token', |
||
118 | ]; |
||
119 | |||
120 | /** |
||
121 | * {@inheritdoc} |
||
122 | */ |
||
123 | protected $observables = [ |
||
124 | 'validating', |
||
125 | 'validated', |
||
126 | ]; |
||
127 | |||
128 | /** |
||
129 | * The attributes to be encrypted before saving. |
||
130 | * |
||
131 | * @var array |
||
132 | */ |
||
133 | protected $hashables = [ |
||
134 | 'password', |
||
135 | ]; |
||
136 | |||
137 | /** |
||
138 | * The default rules that the model will validate against. |
||
139 | * |
||
140 | * @var array |
||
141 | */ |
||
142 | protected $rules = []; |
||
143 | |||
144 | /** |
||
145 | * Whether the model should throw a |
||
146 | * ValidationException if it fails validation. |
||
147 | * |
||
148 | * @var bool |
||
149 | */ |
||
150 | protected $throwValidationExceptions = true; |
||
151 | |||
152 | /** |
||
153 | * Indicates whether to log only dirty attributes or all. |
||
154 | * |
||
155 | * @var bool |
||
156 | */ |
||
157 | protected static $logOnlyDirty = true; |
||
158 | |||
159 | /** |
||
160 | * The attributes that are logged on change. |
||
161 | * |
||
162 | * @var array |
||
163 | */ |
||
164 | protected static $logFillable = true; |
||
165 | |||
166 | /** |
||
167 | * The attributes that are ignored on change. |
||
168 | * |
||
169 | * @var array |
||
170 | */ |
||
171 | protected static $ignoreChangedAttributes = [ |
||
172 | 'password', |
||
173 | 'two_factor', |
||
174 | 'email_verified_at', |
||
175 | 'phone_verified_at', |
||
176 | 'last_activity', |
||
177 | 'created_at', |
||
178 | 'updated_at', |
||
179 | 'deleted_at', |
||
180 | ]; |
||
181 | |||
182 | /** |
||
183 | * Register media collections. |
||
184 | * |
||
185 | * @return void |
||
186 | */ |
||
187 | public function registerMediaCollections(): void |
||
192 | |||
193 | /** |
||
194 | * Attach the given abilities to the model. |
||
195 | * |
||
196 | * @param mixed $abilities |
||
197 | * |
||
198 | * @return void |
||
199 | */ |
||
200 | public function setAbilitiesAttribute($abilities): void |
||
214 | |||
215 | /** |
||
216 | * Attach the given roles to the model. |
||
217 | * |
||
218 | * @param mixed $roles |
||
219 | * |
||
220 | * @return void |
||
221 | */ |
||
222 | public function setRolesAttribute($roles): void |
||
236 | |||
237 | /** |
||
238 | * {@inheritdoc} |
||
239 | */ |
||
240 | protected static function boot() |
||
252 | |||
253 | /** |
||
254 | * The user may have many sessions. |
||
255 | * |
||
256 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
257 | */ |
||
258 | public function sessions(): MorphMany |
||
262 | |||
263 | /** |
||
264 | * The user may have many socialites. |
||
265 | * |
||
266 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
267 | */ |
||
268 | public function socialites(): MorphMany |
||
272 | |||
273 | /** |
||
274 | * Route notifications for the authy channel. |
||
275 | * |
||
276 | * @return int|null |
||
277 | */ |
||
278 | public function routeNotificationForAuthy(): ?int |
||
295 | |||
296 | /** |
||
297 | * Get the user's country. |
||
298 | * |
||
299 | * @return \Rinvex\Country\Country |
||
300 | */ |
||
301 | public function getCountryAttribute(): Country |
||
305 | |||
306 | /** |
||
307 | * Get the user's language. |
||
308 | * |
||
309 | * @return \Rinvex\Language\Language |
||
310 | */ |
||
311 | public function getLanguageAttribute(): Language |
||
315 | |||
316 | /** |
||
317 | * Activate the user. |
||
318 | * |
||
319 | * @return $this |
||
320 | */ |
||
321 | public function activate() |
||
327 | |||
328 | /** |
||
329 | * Deactivate the user. |
||
330 | * |
||
331 | * @return $this |
||
332 | */ |
||
333 | public function deactivate() |
||
339 | } |
||
340 |
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.