Prechádzať zdrojové kódy

Add follower/following methods to profile

Daniel Supernault 7 rokov pred
rodič
commit
842af8669b
1 zmenil súbory, kde vykonal 37 pridanie a 0 odobranie
  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'
+      );
+    }
+}