From 95dcf8f7b374d1e340d5dfc1b7eec3ef006df8d5 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 29 May 2018 21:02:24 -0600 Subject: [PATCH] Update follower model, add new methods --- app/Follower.php | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/app/Follower.php b/app/Follower.php index 597f82aac..b2b8675de 100644 --- a/app/Follower.php +++ b/app/Follower.php @@ -6,5 +6,32 @@ use Illuminate\Database\Eloquent\Model; class Follower extends Model { - // + public function actor() + { + return $this->belongsTo(Profile::class, 'profile_id', 'id'); + } + + public function target() + { + return $this->belongsTo(Profile::class, 'following_id', 'id'); + } + + public function profile() + { + return $this->belongsTo(Profile::class, 'following_id', 'id'); + } + + public function toText() + { + $actorName = $this->actor->username; + return "{$actorName} " . __('notification.startedFollowingYou'); + } + + public function toHtml() + { + $actorName = $this->actor->username; + $actorUrl = $this->actor->url(); + return "{$actorName} " . + __('notification.startedFollowingYou'); + } }