1
0
Эх сурвалжийг харах

Add follower/following methods to profile

Daniel Supernault 7 жил өмнө
parent
commit
842af8669b
1 өөрчлөгдсөн 37 нэмэгдсэн , 0 устгасан
  1. 37 0
      app/Profile.php

+ 37 - 0
app/Profile.php

@@ -0,0 +1,37 @@
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+
+class Profile extends Model
+{
+    public function statuses()
+    {
+      return $this->hasMany(Status::class);
+    }
+
+    public function following()
+    {
+      return $this->hasManyThrough(
+        Profile::class,
+        Follower::class,
+        'profile_id',
+        'id',
+        'id',
+        'id'
+      );
+    }
+
+    public function followers()
+    {
+      return $this->hasManyThrough(
+        Profile::class,
+        Follower::class,
+        'following_id',
+        'id',
+        'id',
+        'id'
+      );
+    }
+}