| 
									
										
										
										
											2018-04-18 02:17:42 +00:00
										 |  |  | <?php | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | namespace App; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  | use Auth, Cache, Storage; | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  | use App\Util\Lexer\PrettyNumber; | 
					
						
							| 
									
										
										
										
											2019-07-12 04:46:32 +00:00
										 |  |  | use Pixelfed\Snowflake\HasSnowflakePrimary; | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  | use Illuminate\Database\Eloquent\{Model, SoftDeletes}; | 
					
						
							| 
									
										
										
										
											2018-04-18 02:17:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | class Profile extends Model | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-07-12 04:46:32 +00:00
										 |  |  |     use HasSnowflakePrimary, SoftDeletes; | 
					
						
							| 
									
										
										
										
											2018-06-14 00:52:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-12 04:46:32 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Indicates if the IDs are auto-incrementing. | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @var bool | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     public $incrementing = false; | 
					
						
							|  |  |  |      | 
					
						
							| 
									
										
										
										
											2020-04-26 08:07:17 +00:00
										 |  |  |     protected $dates = [ | 
					
						
							|  |  |  |         'deleted_at', | 
					
						
							|  |  |  |         'last_fetched_at' | 
					
						
							|  |  |  |     ]; | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  |     protected $hidden = ['private_key']; | 
					
						
							| 
									
										
										
										
											2019-01-12 07:47:00 +00:00
										 |  |  |     protected $visible = ['id', 'user_id', 'username', 'name']; | 
					
						
							| 
									
										
										
										
											2019-06-21 20:04:45 +00:00
										 |  |  |     protected $fillable = ['user_id']; | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-09 23:31:48 +00:00
										 |  |  |     public function user() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->belongsTo(User::class); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  |     public function url($suffix = null) | 
					
						
							| 
									
										
										
										
											2018-07-12 16:40:25 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  |         return $this->remote_url ?? url($this->username . $suffix); | 
					
						
							| 
									
										
										
										
											2018-07-12 16:40:25 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  |     public function localUrl($suffix = null) | 
					
						
							| 
									
										
										
										
											2018-04-19 05:57:16 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  |         return url($this->username . $suffix); | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  |     public function permalink($suffix = null) | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-12-18 06:28:46 +00:00
										 |  |  |         return $this->remote_url ?? url('users/' . $this->username . $suffix); | 
					
						
							| 
									
										
										
										
											2018-04-19 05:57:16 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  |     public function emailUrl() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-10-10 01:25:27 +00:00
										 |  |  |         if($this->domain) { | 
					
						
							|  |  |  |             return $this->username; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |          | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  |         $domain = parse_url(config('app.url'), PHP_URL_HOST); | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return $this->username.'@'.$domain; | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-18 02:17:42 +00:00
										 |  |  |     public function statuses() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |         return $this->hasMany(Status::class); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function followingCount($short = false) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-12-11 05:58:13 +00:00
										 |  |  |         $count = Cache::remember('profile:following_count:'.$this->id, now()->addMonths(1), function() { | 
					
						
							|  |  |  |             $count = $this->following_count; | 
					
						
							|  |  |  |             if($count) { | 
					
						
							|  |  |  |                 return $count; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $count = $this->following()->count(); | 
					
						
							|  |  |  |             $this->following_count = $count; | 
					
						
							|  |  |  |             $this->save(); | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |             return $count; | 
					
						
							| 
									
										
										
										
											2020-12-11 05:58:13 +00:00
										 |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         return $short ? PrettyNumber::convert($count) : $count; | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function followerCount($short = false) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2020-12-11 05:58:13 +00:00
										 |  |  |         $count = Cache::remember('profile:follower_count:'.$this->id, now()->addMonths(1), function() { | 
					
						
							|  |  |  |             $count = $this->followers_count; | 
					
						
							|  |  |  |             if($count) { | 
					
						
							|  |  |  |                 return $count; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $count = $this->followers()->count(); | 
					
						
							|  |  |  |             $this->followers_count = $count; | 
					
						
							|  |  |  |             $this->save(); | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |             return $count; | 
					
						
							| 
									
										
										
										
											2020-12-11 05:58:13 +00:00
										 |  |  |         }); | 
					
						
							|  |  |  |         return $short ? PrettyNumber::convert($count) : $count; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function statusCount() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return Cache::remember('profile:status_count:'.$this->id, now()->addMonths(1), function() { | 
					
						
							|  |  |  |             $count = $this->status_count; | 
					
						
							|  |  |  |             if($count) { | 
					
						
							|  |  |  |                 return $count; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             $count = $this->statuses() | 
					
						
							|  |  |  |                 ->getQuery() | 
					
						
							|  |  |  |                 ->whereHas('media') | 
					
						
							|  |  |  |                 ->whereNull('in_reply_to_id') | 
					
						
							|  |  |  |                 ->whereNull('reblog_of_id') | 
					
						
							|  |  |  |                 ->count(); | 
					
						
							|  |  |  |             $this->status_count = $count; | 
					
						
							|  |  |  |             $this->save(); | 
					
						
							|  |  |  |             return $count; | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2018-04-18 02:17:42 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function following() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |         return $this->belongsToMany( | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  |             self::class, | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |             'followers', | 
					
						
							|  |  |  |             'profile_id', | 
					
						
							|  |  |  |             'following_id' | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2018-04-18 02:17:42 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function followers() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |         return $this->belongsToMany( | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  |             self::class, | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |             'followers', | 
					
						
							|  |  |  |             'following_id', | 
					
						
							|  |  |  |             'profile_id' | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 01:29:31 +00:00
										 |  |  |     public function follows($profile) : bool | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-09-03 01:29:31 +00:00
										 |  |  |         return Follower::whereProfileId($this->id)->whereFollowingId($profile->id)->exists(); | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 01:29:31 +00:00
										 |  |  |     public function followedBy($profile) : bool | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-09-03 01:29:31 +00:00
										 |  |  |         return Follower::whereProfileId($profile->id)->whereFollowingId($this->id)->exists(); | 
					
						
							| 
									
										
										
										
											2018-05-31 22:03:31 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function bookmarks() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->belongsToMany( | 
					
						
							|  |  |  |             Status::class, | 
					
						
							|  |  |  |             'bookmarks', | 
					
						
							|  |  |  |             'profile_id', | 
					
						
							|  |  |  |             'status_id' | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2018-04-18 02:17:42 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-19 05:57:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function likes() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Like::class); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function avatar() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-08-16 00:21:42 +00:00
										 |  |  |         return $this->hasOne(Avatar::class)->withDefault([ | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  |             'media_path' => 'public/avatars/default.png', | 
					
						
							| 
									
										
										
										
											2019-06-05 07:18:09 +00:00
										 |  |  |             'change_count' => 0 | 
					
						
							| 
									
										
										
										
											2018-08-16 00:21:42 +00:00
										 |  |  |         ]); | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function avatarUrl() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-06-05 07:38:19 +00:00
										 |  |  |         $url = Cache::remember('avatar:'.$this->id, now()->addYears(1), function () { | 
					
						
							| 
									
										
										
										
											2019-06-05 07:18:09 +00:00
										 |  |  |             $avatar = $this->avatar; | 
					
						
							|  |  |  |             $path = $avatar->media_path; | 
					
						
							| 
									
										
										
										
											2020-03-31 01:34:27 +00:00
										 |  |  |             $path = "{$path}?v={$avatar->change_count}"; | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-02 04:35:39 +00:00
										 |  |  |             return config('app.url') . Storage::url($path); | 
					
						
							| 
									
										
										
										
											2018-08-13 03:51:05 +00:00
										 |  |  |         }); | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-22 23:56:20 +00:00
										 |  |  |         return $url; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-07-12 16:40:25 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-05 07:38:19 +00:00
										 |  |  |     // deprecated
 | 
					
						
							| 
									
										
										
										
											2018-08-10 02:10:16 +00:00
										 |  |  |     public function recommendFollowers() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2019-06-05 07:38:19 +00:00
										 |  |  |         return collect([]); | 
					
						
							| 
									
										
										
										
											2018-08-10 02:10:16 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function keyId() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  |         if ($this->remote_url) { | 
					
						
							| 
									
										
										
										
											2018-08-10 02:10:16 +00:00
										 |  |  |             return; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-08-28 03:07:36 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-10 02:10:16 +00:00
										 |  |  |         return $this->permalink('#main-key'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-03 01:29:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function mutedIds() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return UserFilter::whereUserId($this->id) | 
					
						
							|  |  |  |             ->whereFilterableType('App\Profile') | 
					
						
							|  |  |  |             ->whereFilterType('mute') | 
					
						
							|  |  |  |             ->pluck('filterable_id'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-23 23:25:33 +00:00
										 |  |  |     public function blockedIds() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return UserFilter::whereUserId($this->id) | 
					
						
							|  |  |  |             ->whereFilterableType('App\Profile') | 
					
						
							|  |  |  |             ->whereFilterType('block') | 
					
						
							|  |  |  |             ->pluck('filterable_id'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function mutedProfileUrls() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $ids = $this->mutedIds(); | 
					
						
							|  |  |  |         return $this->whereIn('id', $ids)->get()->map(function($i) { | 
					
						
							|  |  |  |             return $i->url(); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function blockedProfileUrls() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         $ids = $this->blockedIds(); | 
					
						
							|  |  |  |         return $this->whereIn('id', $ids)->get()->map(function($i) { | 
					
						
							|  |  |  |             return $i->url(); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-09-03 01:29:31 +00:00
										 |  |  |     public function reports() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Report::class, 'profile_id'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function media() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Media::class, 'profile_id'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-09-16 00:37:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function inboxUrl() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->inbox_url ?? $this->permalink('/inbox'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function outboxUrl() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->outbox_url ?? $this->permalink('/outbox'); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function sharedInbox() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->sharedInbox ?? $this->inboxUrl(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-11-04 03:20:11 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function getDefaultScope() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->is_private == true ? 'private' : 'public'; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function getAudience($scope = false) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if($this->remote_url) { | 
					
						
							|  |  |  |             return []; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         $scope = $scope ?? $this->getDefaultScope(); | 
					
						
							|  |  |  |         $audience = []; | 
					
						
							|  |  |  |         switch ($scope) { | 
					
						
							|  |  |  |             case 'public': | 
					
						
							|  |  |  |                 $audience = [ | 
					
						
							|  |  |  |                     'to' => [ | 
					
						
							|  |  |  |                         'https://www.w3.org/ns/activitystreams#Public' | 
					
						
							|  |  |  |                     ], | 
					
						
							|  |  |  |                     'cc' => [ | 
					
						
							|  |  |  |                         $this->permalink('/followers') | 
					
						
							|  |  |  |                     ] | 
					
						
							|  |  |  |                 ]; | 
					
						
							|  |  |  |                 break; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-11-14 02:16:59 +00:00
										 |  |  |         return $audience; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function getAudienceInbox($scope = 'public') | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this | 
					
						
							|  |  |  |             ->followers() | 
					
						
							|  |  |  |             ->whereLocalProfile(false) | 
					
						
							|  |  |  |             ->get() | 
					
						
							|  |  |  |             ->map(function($follow) { | 
					
						
							|  |  |  |                 return $follow->sharedInbox ?? $follow->inbox_url; | 
					
						
							|  |  |  |              }) | 
					
						
							|  |  |  |             ->unique() | 
					
						
							|  |  |  |             ->toArray(); | 
					
						
							| 
									
										
										
										
											2018-11-04 03:20:11 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-02-10 05:42:04 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function circles() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Circle::class); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-03-02 07:18:23 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function hashtags() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasManyThrough( | 
					
						
							|  |  |  |             Hashtag::class, | 
					
						
							|  |  |  |             StatusHashtag::class, | 
					
						
							|  |  |  |             'profile_id', | 
					
						
							|  |  |  |             'id', | 
					
						
							|  |  |  |             'id', | 
					
						
							|  |  |  |             'hashtag_id' | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-07-11 03:26:05 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function hashtagFollowing() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(HashtagFollow::class); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-07-18 03:04:24 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function collections() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Collection::class); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-07-27 04:47:39 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function hasFollowRequestById(int $id) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return FollowRequest::whereFollowerId($id) | 
					
						
							|  |  |  |             ->whereFollowingId($this->id) | 
					
						
							|  |  |  |             ->exists(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-12-31 09:33:54 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |     public function stories() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Story::class); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-02-12 04:41:16 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     public function reported() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         return $this->hasMany(Report::class, 'object_id'); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-04-18 02:17:42 +00:00
										 |  |  | } |