Follower.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Follower extends Model
  5. {
  6. protected $fillable = ['profile_id', 'following_id', 'local_profile'];
  7. public function actor()
  8. {
  9. return $this->belongsTo(Profile::class, 'profile_id', 'id');
  10. }
  11. public function target()
  12. {
  13. return $this->belongsTo(Profile::class, 'following_id', 'id');
  14. }
  15. public function profile()
  16. {
  17. return $this->belongsTo(Profile::class, 'following_id', 'id');
  18. }
  19. public function permalink($append = null)
  20. {
  21. $path = $this->actor->permalink("#accepts/follows/{$this->id}{$append}");
  22. return url($path);
  23. }
  24. public function toText()
  25. {
  26. $actorName = $this->actor->username;
  27. return "{$actorName} ".__('notification.startedFollowingYou');
  28. }
  29. public function toHtml()
  30. {
  31. $actorName = $this->actor->username;
  32. $actorUrl = $this->actor->url();
  33. return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> ".
  34. __('notification.startedFollowingYou');
  35. }
  36. }