| @@ -20,14 +20,34 @@ | ||
| 20 | 20 | * |
| 21 | 21 | * @package FluentCommunity\App\Models |
| 22 | 22 | * |
| 23 | 23 | * @version 1.1.0 |
| 24 | + * | |
| 25 | + * @property int $id | |
| 26 | + * @property int $user_id | |
| 27 | + * @property int $total_points | |
| 28 | + * @property string|null $username | |
| 29 | + * @property string $status | |
| 30 | + * @property int $is_verified | |
| 31 | + * @property string|null $display_name | |
| 32 | + * @property string|null $avatar | |
| 33 | + * @property string|null $short_description | |
| 34 | + * @property string|null $last_activity | |
| 35 | + * @property mixed $meta | |
| 36 | + * @property mixed $custom_fields | |
| 37 | + * @property object|null $created_at | |
| 38 | + * @property-read mixed $badge | |
| 39 | + * @property-read string $permalink | |
| 40 | + * @property-read \FluentCommunity\App\Models\User|null $user | |
| 41 | + * @property int|null $compilation_score | |
| 42 | + * @property string|null $user_email | |
| 43 | + * @property int|null $ID | |
| 24 | 44 | */ |
| 25 | 45 | class XProfile extends Model |
| 26 | 46 | { |
| 27 | 47 | protected $table = 'fcom_xprofile'; |
| 28 | 48 | |
| 29 | - protected $guarded = ['id']; | |
| 49 | + protected $guarded = [ 'id' ]; | |
| 30 | 50 | |
| 31 | 51 | protected $primaryKey = 'user_id'; |
| 32 | 52 | |
| 33 | 53 | protected $casts = [ |
| @@ -47,17 +67,17 @@ | ||
| 47 | 67 | 'short_description', |
| 48 | 68 | 'last_activity', |
| 49 | 69 | 'meta', |
| 50 | 70 | 'custom_fields', |
| 51 | - 'created_at' | |
| 71 | + 'created_at', | |
| 52 | 72 | ]; |
| 53 | 73 | |
| 54 | 74 | protected $searchable = [ |
| 55 | 75 | 'display_name', |
| 56 | - 'username' | |
| 76 | + 'username', | |
| 57 | 77 | ]; |
| 58 | 78 | |
| 59 | - protected $appends = ['badge', 'permalink']; | |
| 79 | + protected $appends = [ 'badge', 'permalink' ]; | |
| 60 | 80 | |
| 61 | 81 | public function scopeSearchBy($query, $search) |
| 62 | 82 | { |
| 63 | 83 | if ($search) { |
| @@ -98,9 +118,9 @@ | ||
| 98 | 118 | |
| 99 | 119 | public function spaces() |
| 100 | 120 | { |
| 101 | 121 | return $this->belongsToMany(BaseSpace::class, 'fcom_space_user', 'user_id', 'space_id') |
| 102 | - ->withPivot(['role', 'status', 'created_at']); | |
| 122 | + ->withPivot([ 'role', 'status', 'created_at' ]); | |
| 103 | 123 | } |
| 104 | 124 | |
| 105 | 125 | public function posts() |
| 106 | 126 | { |
| @@ -131,9 +151,9 @@ | ||
| 131 | 151 | |
| 132 | 152 | public function courses() |
| 133 | 153 | { |
| 134 | 154 | return $this->belongsToMany(Course::class, 'fcom_space_user', 'user_id', 'space_id') |
| 135 | - ->withPivot(['role', 'status', 'created_at']); | |
| 155 | + ->withPivot([ 'role', 'status', 'created_at' ]); | |
| 136 | 156 | } |
| 137 | 157 | |
| 138 | 158 | public function space_pivot() |
| 139 | 159 | { |
| @@ -142,8 +162,9 @@ | ||
| 142 | 162 | |
| 143 | 163 | public function community_role() |
| 144 | 164 | { |
| 145 | 165 | return $this->belongsTo(Meta::class, 'user_id', 'object_id') |
| 166 | + ->where('object_type', 'user') | |
| 146 | 167 | ->where('meta_key', '_user_community_roles'); |
| 147 | 168 | } |
| 148 | 169 | |
| 149 | 170 | /** |
| @@ -192,9 +213,9 @@ | ||
| 192 | 213 | } |
| 193 | 214 | |
| 194 | 215 | return get_avatar_url($this->user_id, [ |
| 195 | 216 | 'size' => 128, |
| 196 | - 'default' => apply_filters('fluent_community/default_avatar', 'https://ui-avatars.com/api/' . esc_attr($displayName) . '/128', $this->user_id) | |
| 217 | + 'default' => apply_filters('fluent_community/default_avatar', 'https://ui-avatars.com/api/' . esc_attr($displayName) . '/128', $this->user_id), | |
| 197 | 218 | ]); |
| 198 | 219 | }, WEEK_IN_SECONDS); |
| 199 | 220 | |
| 200 | 221 | if (!$url) { |
| @@ -242,9 +263,9 @@ | ||
| 242 | 263 | if (!$settings) { |
| 243 | 264 | $settings = [ |
| 244 | 265 | 'cover_photo' => '', |
| 245 | 266 | 'badge_slug' => [], |
| 246 | - 'website' => '' | |
| 267 | + 'website' => '', | |
| 247 | 268 | ]; |
| 248 | 269 | } |
| 249 | 270 | |
| 250 | 271 | if (!Utility::canViewUserProfile($this->user_id)) { |
| @@ -249,9 +270,9 @@ | ||
| 249 | 270 | |
| 250 | 271 | if (!Utility::canViewUserProfile($this->user_id)) { |
| 251 | 272 | return [ |
| 252 | 273 | 'cover_photo' => Arr::get($settings, 'cover_photo', ''), |
| 253 | - 'badge_slug' => Arr::get($settings, 'badge_slug', []) | |
| 274 | + 'badge_slug' => Arr::get($settings, 'badge_slug', []), | |
| 254 | 275 | ]; |
| 255 | 276 | } |
| 256 | 277 | |
| 257 | 278 | return $settings; |
| @@ -261,9 +282,9 @@ | ||
| 261 | 282 | { |
| 262 | 283 | if (!$value) { |
| 263 | 284 | $value = [ |
| 264 | 285 | 'cover_photo' => '', |
| 265 | - 'website' => '' | |
| 286 | + 'website' => '', | |
| 266 | 287 | ]; |
| 267 | 288 | } |
| 268 | 289 | |
| 269 | 290 | $this->attributes['meta'] = maybe_serialize($value); |
| @@ -320,9 +341,9 @@ | ||
| 320 | 341 | 'website' => 30, |
| 321 | 342 | 'cover_photo' => 20, |
| 322 | 343 | 'avatar' => 20, |
| 323 | 344 | 'short_description' => 30, |
| 324 | - 'social_links' => 20 | |
| 345 | + 'social_links' => 20, | |
| 325 | 346 | ]; |
| 326 | 347 | |
| 327 | 348 | $score = 0; |
| 328 | 349 | |
| @@ -371,9 +392,9 @@ | ||
| 371 | 392 | { |
| 372 | 393 | return [ |
| 373 | 394 | 'name' => 'user_profile', |
| 374 | 395 | 'params' => [ |
| 375 | - 'username' => $this->username | |
| 376 | - ] | |
| 396 | + 'username' => $this->username, | |
| 397 | + ], | |
| 377 | 398 | ]; |
| 378 | 399 | } |
| 379 | 400 | } |