From 199ce76d794db3dcb5b58cd722e761eb2985f572 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 2 Sep 2018 19:29:31 -0600 Subject: [PATCH] Update Profile model --- app/Profile.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/app/Profile.php b/app/Profile.php index 5381f8a1..4baef2ba 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -101,14 +101,14 @@ class Profile extends Model ); } - public function follows($profile) + public function follows($profile) : bool { - return Follower::whereProfileId($this->id)->whereFollowingId($profile->id)->count(); + return Follower::whereProfileId($this->id)->whereFollowingId($profile->id)->exists(); } - public function followedBy($profile) + public function followedBy($profile) : bool { - return Follower::whereProfileId($profile->id)->whereFollowingId($this->id)->count(); + return Follower::whereProfileId($profile->id)->whereFollowingId($this->id)->exists(); } public function bookmarks() @@ -187,4 +187,22 @@ class Profile extends Model return $this->permalink('#main-key'); } + + public function mutedIds() + { + return UserFilter::whereUserId($this->id) + ->whereFilterableType('App\Profile') + ->whereFilterType('mute') + ->pluck('filterable_id'); + } + + public function reports() + { + return $this->hasMany(Report::class, 'profile_id'); + } + + public function media() + { + return $this->hasMany(Media::class, 'profile_id'); + } }