DirectMessage.php 639 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App;
  3. use Auth;
  4. use Illuminate\Database\Eloquent\Model;
  5. class DirectMessage extends Model
  6. {
  7. public function status()
  8. {
  9. return $this->belongsTo(Status::class, 'status_id', 'id');
  10. }
  11. public function url()
  12. {
  13. return config('app.url') . '/account/direct/m/' . $this->status_id;
  14. }
  15. public function author()
  16. {
  17. return $this->belongsTo(Profile::class, 'from_id', 'id');
  18. }
  19. public function recipient()
  20. {
  21. return $this->belongsTo(Profile::class, 'to_id', 'id');
  22. }
  23. public function me()
  24. {
  25. return Auth::user()->profile->id === $this->from_id;
  26. }
  27. }