2018-04-15 18:52:22 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App;
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
2018-04-17 20:17:30 -06:00
|
|
|
class Follower extends Model
|
2018-04-15 18:52:22 -06:00
|
|
|
{
|
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-10-09 19:21:45 -06:00
|
|
|
{
|
2018-11-03 21:16:19 -06:00
|
|
|
$path = $this->actor->permalink("/follow/{$this->id}{$append}");
|
2018-10-09 19:21:45 -06:00
|
|
|
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');
|
|
|
|
}
|
2018-04-15 18:52:22 -06:00
|
|
|
}
|