1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2025-03-04 18:48:21 +00:00
pixelfed/app/Follower.php

49 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Follower extends Model
{
2018-11-03 21:16:19 -06:00
protected $fillable = ['profile_id', 'following_id', 'local_profile'];
2018-05-29 21:02:24 -06:00
public function actor()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'profile_id', 'id');
2018-05-29 21:02:24 -06:00
}
public function target()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'following_id', 'id');
2018-05-29 21:02:24 -06:00
}
public function profile()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'following_id', 'id');
2018-05-29 21:02:24 -06:00
}
2018-11-03 21:16:19 -06:00
public function permalink($append = null)
{
2018-12-21 12:51:25 -07:00
$path = $this->actor->permalink("#accepts/follows/{$this->id}{$append}");
return url($path);
}
2018-05-29 21:02:24 -06:00
public function toText()
{
2018-08-28 03:07:36 +00:00
$actorName = $this->actor->username;
return "{$actorName} ".__('notification.startedFollowingYou');
2018-05-29 21:02:24 -06:00
}
public function toHtml()
{
2018-08-28 03:07:36 +00:00
$actorName = $this->actor->username;
$actorUrl = $this->actor->url();
return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> ".
2018-05-29 21:02:24 -06:00
__('notification.startedFollowingYou');
}
}