1 | <?php namespace Arcanedev\LaravelMessenger\Models; |
||
24 | class Message extends Model implements MessageContract |
||
25 | { |
||
26 | /* ------------------------------------------------------------------------------------------------ |
||
27 | | Properties |
||
28 | | ------------------------------------------------------------------------------------------------ |
||
29 | */ |
||
30 | /** |
||
31 | * The relationships that should be touched on save. |
||
32 | * |
||
33 | * @var array |
||
34 | */ |
||
35 | protected $touches = ['discussion']; |
||
36 | |||
37 | /** |
||
38 | * The attributes that can be set with Mass Assignment. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $fillable = ['discussion_id', 'user_id', 'body']; |
||
43 | |||
44 | /** |
||
45 | * Validation rules. |
||
46 | * |
||
47 | * @var array |
||
48 | */ |
||
49 | protected $rules = [ |
||
50 | 'body' => 'required', |
||
51 | ]; |
||
52 | |||
53 | /* ------------------------------------------------------------------------------------------------ |
||
54 | | Constructor |
||
55 | | ------------------------------------------------------------------------------------------------ |
||
56 | */ |
||
57 | /** |
||
58 | * Create a new Eloquent model instance. |
||
59 | * |
||
60 | * @param array $attributes |
||
61 | */ |
||
62 | public function __construct(array $attributes = []) |
||
70 | |||
71 | /* ------------------------------------------------------------------------------------------------ |
||
72 | | Relationships |
||
73 | | ------------------------------------------------------------------------------------------------ |
||
74 | */ |
||
75 | /** |
||
76 | * Discussion relationship. |
||
77 | * |
||
78 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
79 | */ |
||
80 | public function discussion() |
||
86 | |||
87 | /** |
||
88 | * User/Author relationship (alias). |
||
89 | * |
||
90 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
91 | */ |
||
92 | public function author() |
||
96 | |||
97 | /** |
||
98 | * User/Author relationship. |
||
99 | * |
||
100 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
101 | */ |
||
102 | public function user() |
||
108 | |||
109 | /** |
||
110 | * Participants relationship. |
||
111 | * |
||
112 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
113 | */ |
||
114 | public function participants() |
||
122 | |||
123 | /* ------------------------------------------------------------------------------------------------ |
||
124 | | Getters & Setters |
||
125 | | ------------------------------------------------------------------------------------------------ |
||
126 | */ |
||
127 | /** |
||
128 | * Recipients of this message. |
||
129 | * |
||
130 | * @return \Illuminate\Database\Eloquent\Collection |
||
131 | */ |
||
132 | public function getRecipientsAttribute() |
||
138 | } |
||
139 |