FollowRequest.php 889 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class FollowRequest extends Model
  5. {
  6. protected $fillable = ['follower_id', 'following_id', 'activity', 'handled_at'];
  7. protected $casts = [
  8. 'activity' => 'array',
  9. ];
  10. public function actor()
  11. {
  12. return $this->belongsTo(Profile::class, 'follower_id', 'id');
  13. }
  14. public function follower()
  15. {
  16. return $this->belongsTo(Profile::class, 'follower_id', 'id');
  17. }
  18. public function following()
  19. {
  20. return $this->belongsTo(Profile::class, 'following_id', 'id');
  21. }
  22. public function target()
  23. {
  24. return $this->belongsTo(Profile::class, 'following_id', 'id');
  25. }
  26. public function permalink($append = null, $namespace = '#accepts')
  27. {
  28. $path = $this->target->permalink("{$namespace}/follows/{$this->id}{$append}");
  29. return url($path);
  30. }
  31. }