1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-27 18:26:50 +00:00
pixelfed/app/Follower.php

52 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Follower extends Model
{
2018-11-04 03:16:19 +00:00
protected $fillable = ['profile_id', 'following_id', 'local_profile'];
2019-06-02 02:18:21 +00:00
const MAX_FOLLOWING = 7500;
const FOLLOW_PER_HOUR = 20;
2018-05-30 03:02:24 +00:00
public function actor()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'profile_id', 'id');
2018-05-30 03:02:24 +00:00
}
public function target()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'following_id', 'id');
2018-05-30 03:02:24 +00:00
}
public function profile()
{
2018-08-28 03:07:36 +00:00
return $this->belongsTo(Profile::class, 'following_id', 'id');
2018-05-30 03:02:24 +00:00
}
2018-11-04 03:16:19 +00:00
public function permalink($append = null)
{
2018-12-21 19:51:25 +00:00
$path = $this->actor->permalink("#accepts/follows/{$this->id}{$append}");
return url($path);
}
2018-05-30 03:02:24 +00:00
public function toText()
{
2018-08-28 03:07:36 +00:00
$actorName = $this->actor->username;
return "{$actorName} ".__('notification.startedFollowingYou');
2018-05-30 03:02:24 +00: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-30 03:02:24 +00:00
__('notification.startedFollowingYou');
}
}