1 | <?php |
||
30 | class Message extends Model implements MessageContract |
||
31 | { |
||
32 | /* ----------------------------------------------------------------- |
||
33 | | Properties |
||
34 | | ----------------------------------------------------------------- |
||
35 | */ |
||
36 | |||
37 | /** |
||
38 | * The relationships that should be touched on save. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $touches = ['discussion']; |
||
43 | |||
44 | /** |
||
45 | * The attributes that can be set with Mass Assignment. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $fillable = [ |
||
50 | 'discussion_id', |
||
51 | 'body', |
||
52 | ]; |
||
53 | |||
54 | /** |
||
55 | * The attributes that should be mutated to dates. |
||
56 | * |
||
57 | * @var array |
||
58 | */ |
||
59 | protected $dates = ['deleted_at']; |
||
60 | |||
61 | /** |
||
62 | * The attributes that should be cast to native types. |
||
63 | * |
||
64 | * @var array |
||
65 | */ |
||
66 | protected $casts = [ |
||
67 | 'id' => 'integer', |
||
68 | 'discussion_id' => 'integer', |
||
69 | 'participable_id' => 'integer', |
||
70 | ]; |
||
71 | |||
72 | /* ----------------------------------------------------------------- |
||
73 | | Constructor |
||
74 | | ----------------------------------------------------------------- |
||
75 | */ |
||
76 | |||
77 | /** |
||
78 | * Create a new Eloquent model instance. |
||
79 | * |
||
80 | * @param array $attributes |
||
81 | */ |
||
82 | 72 | public function __construct(array $attributes = []) |
|
90 | |||
91 | /* ----------------------------------------------------------------- |
||
92 | | Relationships |
||
93 | | ----------------------------------------------------------------- |
||
94 | */ |
||
95 | |||
96 | /** |
||
97 | * Discussion relationship. |
||
98 | * |
||
99 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
100 | */ |
||
101 | 66 | public function discussion() |
|
107 | |||
108 | /** |
||
109 | * User/Author relationship (alias). |
||
110 | * |
||
111 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
112 | */ |
||
113 | 12 | public function author() |
|
117 | |||
118 | /** |
||
119 | * Participable relationship. |
||
120 | * |
||
121 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
122 | */ |
||
123 | 12 | public function participable() |
|
127 | |||
128 | /** |
||
129 | * Participations relationship. |
||
130 | * |
||
131 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
132 | */ |
||
133 | 6 | public function participations() |
|
141 | |||
142 | /* ----------------------------------------------------------------- |
||
143 | | Getters & Setters |
||
144 | | ----------------------------------------------------------------- |
||
145 | */ |
||
146 | |||
147 | /** |
||
148 | * Recipients of this message. |
||
149 | * |
||
150 | * @return \Illuminate\Database\Eloquent\Collection |
||
151 | */ |
||
152 | 6 | public function getRecipientsAttribute() |
|
161 | } |
||
162 |