Like.php 950 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. class Like 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. protected $fillable = ['profile_id', 'status_id'];
  15. public function actor()
  16. {
  17. return $this->belongsTo(Profile::class, 'profile_id', 'id');
  18. }
  19. public function status()
  20. {
  21. return $this->belongsTo(Status::class);
  22. }
  23. public function toText()
  24. {
  25. $actorName = $this->actor->username;
  26. return "{$actorName} ".__('notification.likedPhoto');
  27. }
  28. public function toHtml()
  29. {
  30. $actorName = $this->actor->username;
  31. $actorUrl = $this->actor->url();
  32. return "<a href='{$actorUrl}' class='profile-link'>{$actorName}</a> ".
  33. __('notification.likedPhoto');
  34. }
  35. }