Mention.php 953 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. class Mention extends Model
  6. {
  7. use SoftDeletes;
  8. /**
  9. * The attributes that should be mutated to dates.
  10. *
  11. * @var array
  12. */
  13. protected $dates = ['deleted_at'];
  14. public function profile()
  15. {
  16. return $this->belongsTo(Profile::class, 'profile_id', 'id');
  17. }
  18. public function status()
  19. {
  20. return $this->belongsTo(Status::class, 'status_id', 'id');
  21. }
  22. public function toText()
  23. {
  24. $actorName = $this->status->profile->username;
  25. return "{$actorName} ".__('notification.mentionedYou');
  26. }
  27. public function toHtml()
  28. {
  29. $actorName = $this->status->profile->username;
  30. $actorUrl = $this->status->profile->url();
  31. return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> ".
  32. __('notification.mentionedYou');
  33. }
  34. }