Просмотр файла app/Models/Message2.php

Размер файла: 1.1Kb
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. namespace App\Models;
  6.  
  7. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  8.  
  9. /**
  10. * Class Inbox
  11. *
  12. * @property int id
  13. * @property int user_id
  14. * @property int author_id
  15. * @property string text
  16. * @property int created_at
  17. */
  18. class Message2 extends BaseModel
  19. {
  20. public const IN = 'in'; // Принятые
  21. public const OUT = 'out'; // Отправленные
  22.  
  23. /**
  24. * The table associated with the model.
  25. *
  26. * @var string
  27. */
  28. protected $table = 'messages2';
  29.  
  30. /**
  31. * Indicates if the model should be timestamped.
  32. *
  33. * @var bool
  34. */
  35. public $timestamps = false;
  36.  
  37. /**
  38. * The attributes that aren't mass assignable.
  39. *
  40. * @var array
  41. */
  42. protected $guarded = [];
  43.  
  44. /**
  45. * Morph name
  46. *
  47. * @var string
  48. */
  49. public static $morphName = 'messages';
  50.  
  51. /**
  52. * Возвращает связь пользователей
  53. *
  54. * @return BelongsTo
  55. */
  56. public function author(): BelongsTo
  57. {
  58. return $this->belongsTo(User::class, 'author_id')->withDefault();
  59. }
  60. }