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 | UserEntity, |
||
37 | UserPresenter; |
||
38 | |||
39 | /** |
||
40 | * The attributes that are mass assignable. |
||
41 | * |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $fillable = [ |
||
45 | 'username', |
||
46 | 'email', |
||
47 | 'password', |
||
48 | 'slug', |
||
49 | 'register_ip', |
||
50 | 'last_login_ip', |
||
51 | 'last_login' |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * The attributes that should be hidden for arrays. |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $hidden = [ |
||
60 | 'password', |
||
61 | 'remember_token' |
||
62 | ]; |
||
63 | |||
64 | /** |
||
65 | * The accessors to append to the model's array form. |
||
66 | * |
||
67 | * @var array |
||
68 | */ |
||
69 | protected $appends = [ |
||
70 | 'profile_background', |
||
71 | |||
72 | // Media Model |
||
73 | 'avatar_small', |
||
74 | 'avatar_medium', |
||
75 | 'avatar_big', |
||
76 | |||
77 | // Account Model |
||
78 | 'first_name', |
||
79 | 'last_name', |
||
80 | 'biography', |
||
81 | 'signature', |
||
82 | 'facebook', |
||
83 | 'twitter' |
||
84 | ]; |
||
85 | |||
86 | /** |
||
87 | * The "booting" method of the model. |
||
88 | * |
||
89 | * @return void |
||
90 | */ |
||
91 | protected static function boot() |
||
100 | |||
101 | /** |
||
102 | * Return the field to slug. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function slugStrategy(): string |
||
110 | |||
111 | /** |
||
112 | * Register the related to the Model. |
||
113 | * |
||
114 | * @return void |
||
115 | */ |
||
116 | public function registerMediaConversions() |
||
136 | |||
137 | /** |
||
138 | * Get the comments for the user. |
||
139 | * |
||
140 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
141 | */ |
||
142 | public function comments() |
||
146 | |||
147 | /** |
||
148 | * Get the articles for the user. |
||
149 | * |
||
150 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
151 | */ |
||
152 | public function articles() |
||
156 | |||
157 | /** |
||
158 | * Get the account for the user. |
||
159 | * |
||
160 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
161 | */ |
||
162 | public function account() |
||
166 | |||
167 | /** |
||
168 | * Get the roles for the user. |
||
169 | * |
||
170 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
171 | */ |
||
172 | public function roles() |
||
176 | |||
177 | /** |
||
178 | * Get the badges for the user. |
||
179 | * |
||
180 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
181 | */ |
||
182 | public function badges() |
||
186 | |||
187 | /** |
||
188 | * Get the notifications for the user. |
||
189 | * |
||
190 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
191 | */ |
||
192 | public function notifications() |
||
198 | |||
199 | /** |
||
200 | * Send the password reset notification. |
||
201 | * |
||
202 | * @param string $token |
||
203 | * |
||
204 | * @return void |
||
205 | */ |
||
206 | public function sendPasswordResetNotification($token) |
||
210 | |||
211 | /** |
||
212 | * Get all permissions from roles. |
||
213 | * |
||
214 | * @return \Illuminate\Database\Eloquent\Builder |
||
215 | */ |
||
216 | public function rolePermissions(): Builder |
||
243 | } |
||
244 |