1 | <?php |
||
22 | class User extends Model implements |
||
23 | AuthenticatableContract, |
||
24 | AuthorizableContract, |
||
25 | CanResetPasswordContract, |
||
26 | HasRoleAndPermissionContract, |
||
27 | HasMediaConversions |
||
28 | { |
||
29 | use Authenticatable, |
||
30 | Authorizable, |
||
31 | CanResetPassword, |
||
32 | Notifiable, |
||
33 | Sluggable, |
||
34 | HasRoleAndPermission, |
||
35 | HasMediaTrait, |
||
36 | UserPresenter; |
||
37 | |||
38 | /** |
||
39 | * The attributes that are mass assignable. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $fillable = [ |
||
44 | 'username', |
||
45 | 'email', |
||
46 | 'password', |
||
47 | 'slug', |
||
48 | 'github_id', |
||
49 | 'xp_total', |
||
50 | 'rubies_total', |
||
51 | 'register_ip', |
||
52 | 'last_login_ip', |
||
53 | 'last_login' |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * The attributes that should be hidden for arrays. |
||
58 | * |
||
59 | * @var array |
||
60 | */ |
||
61 | protected $hidden = [ |
||
62 | 'password', |
||
63 | 'remember_token' |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * The accessors to append to the model's array form. |
||
68 | * |
||
69 | * @var array |
||
70 | */ |
||
71 | protected $appends = [ |
||
72 | 'profile_background', |
||
73 | 'profile_url', |
||
74 | |||
75 | // Media Model |
||
76 | 'avatar_small', |
||
77 | 'avatar_medium', |
||
78 | 'avatar_big', |
||
79 | 'avatar_primary_color', |
||
80 | |||
81 | // Account Model |
||
82 | 'first_name', |
||
83 | 'last_name', |
||
84 | 'full_name', |
||
85 | 'biography', |
||
86 | 'signature', |
||
87 | 'facebook', |
||
88 | 'twitter' |
||
89 | ]; |
||
90 | |||
91 | /** |
||
92 | * The attributes that should be mutated to dates. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $dates = [ |
||
97 | 'last_login' |
||
98 | ]; |
||
99 | |||
100 | /** |
||
101 | * The "booting" method of the model. |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | protected static function boot() |
||
128 | |||
129 | /** |
||
130 | * Return the field to slug. |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | public function slugStrategy(): string |
||
138 | |||
139 | /** |
||
140 | * Register the related to the Model. |
||
141 | * |
||
142 | * @return void |
||
143 | */ |
||
144 | public function registerMediaConversions(Media $media = null) |
||
164 | |||
165 | /** |
||
166 | * Get the comments for the user. |
||
167 | * |
||
168 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
169 | */ |
||
170 | public function comments() |
||
174 | |||
175 | /** |
||
176 | * Get the articles for the user. |
||
177 | * |
||
178 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
179 | */ |
||
180 | public function articles() |
||
184 | |||
185 | /** |
||
186 | * Get the account for the user. |
||
187 | * |
||
188 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
189 | */ |
||
190 | public function account() |
||
194 | |||
195 | /** |
||
196 | * Get the roles for the user. |
||
197 | * |
||
198 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
199 | */ |
||
200 | public function roles() |
||
204 | |||
205 | /** |
||
206 | * Get the badges for the user. |
||
207 | * |
||
208 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
209 | */ |
||
210 | public function badges() |
||
214 | |||
215 | /** |
||
216 | * Get the notifications for the user. |
||
217 | * |
||
218 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
219 | */ |
||
220 | public function notifications() |
||
226 | |||
227 | /** |
||
228 | * Get the discuss posts for the user. |
||
229 | * |
||
230 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
231 | */ |
||
232 | public function discussPosts() |
||
236 | |||
237 | /** |
||
238 | * Get the discuss conversations for the user. |
||
239 | * |
||
240 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
241 | */ |
||
242 | public function discussConversations() |
||
246 | |||
247 | /** |
||
248 | * Get the discuss users for the user. |
||
249 | * |
||
250 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
251 | */ |
||
252 | public function discussUsers() |
||
256 | |||
257 | /** |
||
258 | * Get the discuss logs for the user. |
||
259 | * |
||
260 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
261 | */ |
||
262 | public function discussLogs() |
||
266 | |||
267 | /** |
||
268 | * Get the users rubies for the user. |
||
269 | * |
||
270 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
271 | */ |
||
272 | public function usersRubies() |
||
276 | |||
277 | /** |
||
278 | * Get the users experiences for the user. |
||
279 | * |
||
280 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
281 | */ |
||
282 | public function usersExperiences() |
||
286 | |||
287 | /** |
||
288 | * Send the password reset notification. |
||
289 | * |
||
290 | * @param string $token |
||
291 | * |
||
292 | * @return void |
||
293 | */ |
||
294 | public function sendPasswordResetNotification($token) |
||
298 | |||
299 | /** |
||
300 | * Get all permissions from roles. |
||
301 | * |
||
302 | * @return \Illuminate\Database\Eloquent\Builder |
||
303 | */ |
||
304 | public function rolePermissions(): Builder |
||
331 | } |
||
332 |