瀏覽代碼

Update Status model, add new methods

Daniel Supernault 7 年之前
父節點
當前提交
203034b971
共有 1 個文件被更改,包括 13 次插入0 次删除
  1. 13 0
      app/Status.php

+ 13 - 0
app/Status.php

@@ -52,6 +52,14 @@ class Status extends Model
       return url($path);
     }
 
+    public function permalink($suffix = '/activity')
+    {
+      $id = $this->id;
+      $username = $this->profile->username;
+      $path = config('app.url') . "/p/{$username}/{$id}{$suffix}";
+      return url($path);
+    }
+
     public function editUrl()
     {
       return $this->url() . '/edit';
@@ -174,4 +182,9 @@ class Status extends Model
       return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> " .
           __('notification.commented');
     }
+
+    public function recentComments()
+    {
+      return $this->comments()->orderBy('created_at','desc')->take(3);
+    }
 }