Skip to content

Commit a0101ec

Browse files
committed
make methods chainable
1 parent 0d195e8 commit a0101ec

File tree

1 file changed

+50
-30
lines changed

1 file changed

+50
-30
lines changed

src/Concerns/InteractsWithTickets.php

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,43 @@ trait InteractsWithTickets
99
/**
1010
* Archive the ticket
1111
*
12-
* @return bool
12+
* @return self
1313
*/
14-
public function archive(): bool
14+
public function archive(): self
1515
{
16-
return $this->update([
16+
$this->update([
1717
'status' => Status::ARCHIVED->value,
1818
]);
19+
20+
return $this;
1921
}
2022

2123
/**
2224
* Close the ticket
2325
*
24-
* @return bool
26+
* @return self
2527
*/
26-
public function close(): bool
28+
public function close(): self
2729
{
28-
return $this->update([
30+
$this->update([
2931
'status' => Status::CLOSED->value,
3032
]);
33+
34+
return $this;
3135
}
3236

3337
/**
3438
* Reopen the ticket
3539
*
36-
* @return bool
40+
* @return self
3741
*/
38-
public function reopen(): bool
42+
public function reopen(): self
3943
{
40-
return $this->update([
44+
$this->update([
4145
'status' => Status::OPEN->value,
4246
]);
47+
48+
return $this;
4349
}
4450

4551
/**
@@ -125,87 +131,101 @@ public function delete(): bool
125131
/**
126132
* Mark the ticket as resolved
127133
*
128-
* @return bool
134+
* @return self
129135
*/
130-
public function markAsResolved(): bool
136+
public function markAsResolved(): self
131137
{
132-
return $this->update([
138+
$this->update([
133139
'is_resolved' => true,
134140
]);
141+
142+
return $this;
135143
}
136144

137145
/**
138146
* Mark the ticket as locked
139147
*
140-
* @return bool
148+
* @return self
141149
*/
142-
public function markAsLocked(): bool
150+
public function markAsLocked(): self
143151
{
144-
return $this->update([
152+
$this->update([
145153
'is_locked' => true,
146154
]);
155+
156+
return $this;
147157
}
148158

149159
/**
150160
* Mark the ticket as locked
151161
*
152-
* @return bool
162+
* @return self
153163
*/
154-
public function markAsUnlocked(): bool
164+
public function markAsUnlocked(): self
155165
{
156-
return $this->update([
166+
$this->update([
157167
'is_locked' => false,
158168
]);
169+
170+
return $this;
159171
}
160172

161173
/**
162174
* Mark the ticket as archived
163175
*
164-
* @return bool
176+
* @return self
165177
*/
166-
public function markAsArchived(): bool
178+
public function markAsArchived(): self
167179
{
168-
return $this->update([
180+
$this->update([
169181
'status' => Status::ARCHIVED->value,
170182
]);
183+
184+
return $this;
171185
}
172186

173187
/**
174188
* Close the ticket and mark it as resolved
175189
*
176-
* @return bool
190+
* @return self
177191
*/
178-
public function closeAsResolved(): bool
192+
public function closeAsResolved(): self
179193
{
180-
return $this->update([
194+
$this->update([
181195
'status' => Status::CLOSED->value,
182196
'is_resolved' => true,
183197
]);
198+
199+
return $this;
184200
}
185201

186202
/**
187203
* Close the ticket and mark it as unresolved
188204
*
189-
* @return bool
205+
* @return self
190206
*/
191-
public function closeAsUnResolved(): bool
207+
public function closeAsUnResolved(): self
192208
{
193-
return $this->update([
209+
$this->update([
194210
'status' => Status::CLOSED->value,
195211
'is_resolved' => false,
196212
]);
213+
214+
return $this;
197215
}
198216

199217
/**
200218
* Reopen the ticket and mark it as resolved
201219
*
202-
* @return bool
220+
* @return self
203221
*/
204-
public function reopenAsUnresolved(): bool
222+
public function reopenAsUnresolved(): self
205223
{
206-
return $this->update([
224+
$this->update([
207225
'status' => Status::OPEN->value,
208226
'is_resolved' => false,
209227
]);
228+
229+
return $this;
210230
}
211231
}

0 commit comments

Comments
 (0)