Follower.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. const MAX_FOLLOWING = 7500;
  8. const FOLLOW_PER_HOUR = 150;
  9. public function actor()
  10. {
  11. return $this->belongsTo(Profile::class, 'profile_id', 'id');
  12. }
  13. public function target()
  14. {
  15. return $this->belongsTo(Profile::class, 'following_id', 'id');
  16. }
  17. public function profile()
  18. {
  19. return $this->belongsTo(Profile::class, 'following_id', 'id');
  20. }
  21. public function permalink($append = null)
  22. {
  23. $path = $this->actor->permalink("#accepts/follows/{$this->id}{$append}");
  24. return url($path);
  25. }
  26. public function toText()
  27. {
  28. $actorName = $this->actor->username;
  29. return "{$actorName} ".__('notification.startedFollowingYou');
  30. }
  31. public function toHtml()
  32. {
  33. $actorName = $this->actor->username;
  34. $actorUrl = $this->actor->url();
  35. return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> ".
  36. __('notification.startedFollowingYou');
  37. }
  38. }