浏览代码

Update Profile model

Daniel Supernault 6 年之前
父节点
当前提交
2982182b3d
共有 1 个文件被更改,包括 24 次插入0 次删除
  1. 24 0
      app/Profile.php

+ 24 - 0
app/Profile.php

@@ -196,6 +196,30 @@ class Profile extends Model
             ->pluck('filterable_id');
     }
 
+    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();
+        });
+    }
+
     public function reports()
     {
         return $this->hasMany(Report::class, 'profile_id');