1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Timegridio\Concierge\Models; |
4
|
|
|
|
5
|
|
|
use Carbon\Carbon; |
6
|
|
|
use Illuminate\Database\Eloquent\Model as EloquentModel; |
7
|
|
|
use McCool\LaravelAutoPresenter\HasPresenter; |
8
|
|
|
use Timegridio\Concierge\Presenters\AppointmentPresenter; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* An Appointment can be understood as a reservation of a given Service, |
12
|
|
|
* provided by a given Business, targeted to a Contact, which will take place |
13
|
|
|
* on a determined Date and Time, and might have a duration and or comments. |
14
|
|
|
* |
15
|
|
|
* The Appointment can be issued by the Contact's User or by the Business owner. |
16
|
|
|
*/ |
17
|
|
|
class Appointment extends EloquentModel implements HasPresenter |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* The attributes that are mass assignable. |
21
|
|
|
* |
22
|
|
|
* @var array |
23
|
|
|
*/ |
24
|
|
|
protected $fillable = ['issuer_id', 'contact_id', 'business_id', |
25
|
|
|
'service_id', 'start_at', 'finish_at', 'duration', 'comments', ]; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* The attributes that aren't mass assignable. |
29
|
|
|
* |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
protected $guarded = ['id', 'hash', 'status', 'vacancy_id']; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* The attributes that should be mutated to dates. |
36
|
|
|
* |
37
|
|
|
* @var array |
38
|
|
|
*/ |
39
|
|
|
protected $dates = ['start_at', 'finish_at']; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Appointment Hard Status Constants. |
43
|
|
|
*/ |
44
|
|
|
const STATUS_RESERVED = 'R'; |
45
|
|
|
const STATUS_CONFIRMED = 'C'; |
46
|
|
|
const STATUS_ANNULATED = 'A'; |
47
|
|
|
const STATUS_SERVED = 'S'; |
48
|
|
|
|
49
|
|
|
/////////////// |
50
|
|
|
// PRESENTER // |
51
|
|
|
/////////////// |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Get Presenter Class. |
55
|
|
|
* |
56
|
|
|
* @return App\Presenters\AppointmentPresenter |
57
|
|
|
*/ |
58
|
|
|
public function getPresenterClass() |
59
|
|
|
{ |
60
|
|
|
return AppointmentPresenter::class; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Generate hash and save the model to the database. |
65
|
|
|
* |
66
|
|
|
* @param array $options |
67
|
|
|
* |
68
|
|
|
* @return bool |
69
|
|
|
*/ |
70
|
|
|
public function save(array $options = []) |
71
|
|
|
{ |
72
|
|
|
$this->doHash(); |
73
|
|
|
|
74
|
|
|
return parent::save($options); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/////////////////// |
78
|
|
|
// Relationships // |
79
|
|
|
/////////////////// |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Get the issuer (the User that generated the Appointment). |
83
|
|
|
* |
84
|
|
|
* @return Illuminate\Database\Eloquent\belongsTo |
85
|
|
|
*/ |
86
|
|
|
public function issuer() |
87
|
|
|
{ |
88
|
|
|
return $this->belongsTo(config('auth.providers.users.model')); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Get the target Contact (for whom is reserved the Appointment). |
93
|
|
|
* |
94
|
|
|
* @return Illuminate\Database\Eloquent\belongsTo |
95
|
|
|
*/ |
96
|
|
|
public function contact() |
97
|
|
|
{ |
98
|
|
|
return $this->belongsTo(Contact::class); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Get the holding Business (that has taken the reservation). |
103
|
|
|
* |
104
|
|
|
* @return Illuminate\Database\Eloquent\belongsTo |
105
|
|
|
*/ |
106
|
|
|
public function business() |
107
|
|
|
{ |
108
|
|
|
return $this->belongsTo(Business::class); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* Get the reserved Service. |
113
|
|
|
* |
114
|
|
|
* @return Illuminate\Database\Eloquent\belongsTo |
115
|
|
|
*/ |
116
|
|
|
public function service() |
117
|
|
|
{ |
118
|
|
|
return $this->belongsTo(Service::class); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Get the Vacancy (that justifies the availability of resources for the |
123
|
|
|
* Appointment generation). |
124
|
|
|
* |
125
|
|
|
* @return Illuminate\Database\Eloquent\belongsTo |
126
|
|
|
*/ |
127
|
|
|
public function vacancy() |
128
|
|
|
{ |
129
|
|
|
return $this->belongsTo(Vacancy::class); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/////////// |
133
|
|
|
// Other // |
134
|
|
|
/////////// |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* Get the User through Contact. |
138
|
|
|
* |
139
|
|
|
* @return User |
140
|
|
|
*/ |
141
|
|
|
public function user() |
142
|
|
|
{ |
143
|
|
|
return $this->contact->user; |
|
|
|
|
144
|
|
|
} |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* Determine if the new Appointment will hash-crash with another existing |
148
|
|
|
* Appointment. |
149
|
|
|
* |
150
|
|
|
* @return bool |
151
|
|
|
*/ |
152
|
|
|
public function duplicates() |
153
|
|
|
{ |
154
|
|
|
return !self::where('hash', $this->hash)->get()->isEmpty(); |
|
|
|
|
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/////////////// |
158
|
|
|
// Accessors // |
159
|
|
|
/////////////// |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* Get Hash. |
163
|
|
|
* |
164
|
|
|
* @return string |
165
|
|
|
*/ |
166
|
|
|
public function getHashAttribute() |
167
|
|
|
{ |
168
|
|
|
return isset($this->attributes['hash']) |
169
|
|
|
? $this->attributes['hash'] |
170
|
|
|
: $this->doHash(); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Get Finish At: |
175
|
|
|
* Calculates the start_at time plus duration in minutes. |
176
|
|
|
* |
177
|
|
|
* @return Carbon |
178
|
|
|
*/ |
179
|
|
|
public function getFinishAtAttribute() |
180
|
|
|
{ |
181
|
|
|
if (array_get($this->attributes, 'finish_at') !== null) { |
182
|
|
|
return Carbon::parse($this->attributes['finish_at']); |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
if (is_numeric($this->duration)) { |
|
|
|
|
186
|
|
|
return $this->start_at->addMinutes($this->duration); |
|
|
|
|
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
return $this->start_at; |
|
|
|
|
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* Get TimeZone (from the Business). |
194
|
|
|
* |
195
|
|
|
* @return string |
196
|
|
|
*/ |
197
|
|
|
public function getTZAttribute() |
198
|
|
|
{ |
199
|
|
|
return $this->business->timezone; |
|
|
|
|
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* Get the human readable status name. |
204
|
|
|
* |
205
|
|
|
* @return string |
206
|
|
|
*/ |
207
|
|
|
public function getStatusLabelAttribute() |
208
|
|
|
{ |
209
|
|
|
$labels = [ |
210
|
|
|
Self::STATUS_RESERVED => 'reserved', |
211
|
|
|
Self::STATUS_CONFIRMED => 'confirmed', |
212
|
|
|
Self::STATUS_ANNULATED => 'annulated', |
213
|
|
|
Self::STATUS_SERVED => 'served', |
214
|
|
|
]; |
215
|
|
|
|
216
|
|
|
return array_key_exists($this->status, $labels) |
|
|
|
|
217
|
|
|
? $labels[$this->status] |
|
|
|
|
218
|
|
|
: ''; |
219
|
|
|
} |
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Get the date of the Appointment. |
223
|
|
|
* |
224
|
|
|
* @return string |
225
|
|
|
*/ |
226
|
|
|
public function getDateAttribute() |
227
|
|
|
{ |
228
|
|
|
return $this->start_at |
|
|
|
|
229
|
|
|
->timezone($this->business->timezone) |
|
|
|
|
230
|
|
|
->toDateString(); |
231
|
|
|
} |
232
|
|
|
|
233
|
|
|
////////////// |
234
|
|
|
// Mutators // |
235
|
|
|
////////////// |
236
|
|
|
|
237
|
|
|
/** |
238
|
|
|
* Generate Appointment hash. |
239
|
|
|
* |
240
|
|
|
* @return string |
241
|
|
|
*/ |
242
|
|
|
public function doHash() |
243
|
|
|
{ |
244
|
|
|
return $this->attributes['hash'] = md5( |
245
|
|
|
$this->start_at.'/'. |
|
|
|
|
246
|
|
|
$this->contact_id.'/'. |
|
|
|
|
247
|
|
|
$this->business_id.'/'. |
|
|
|
|
248
|
|
|
$this->service_id |
|
|
|
|
249
|
|
|
); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Set start at. |
254
|
|
|
* |
255
|
|
|
* @param Carbon $datetime |
256
|
|
|
*/ |
257
|
|
|
public function setStartAtAttribute(Carbon $datetime) |
258
|
|
|
{ |
259
|
|
|
$this->attributes['start_at'] = $datetime; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* Set finish_at attribute. |
264
|
|
|
* |
265
|
|
|
* @param Carbon $datetime |
266
|
|
|
*/ |
267
|
|
|
public function setFinishAtAttribute(Carbon $datetime) |
268
|
|
|
{ |
269
|
|
|
$this->attributes['finish_at'] = $datetime; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* Set Comments. |
274
|
|
|
* |
275
|
|
|
* @param string $comments |
276
|
|
|
*/ |
277
|
|
|
public function setCommentsAttribute($comments) |
278
|
|
|
{ |
279
|
|
|
$this->attributes['comments'] = trim($comments) ?: null; |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
///////////////// |
283
|
|
|
// HARD STATUS // |
284
|
|
|
///////////////// |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* Determine if is Reserved. |
288
|
|
|
* |
289
|
|
|
* @return bool |
290
|
|
|
*/ |
291
|
|
|
public function isReserved() |
292
|
|
|
{ |
293
|
|
|
return $this->status == Self::STATUS_RESERVED; |
|
|
|
|
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
/////////////////////////// |
297
|
|
|
// Calculated attributes // |
298
|
|
|
/////////////////////////// |
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* Appointment Status Workflow. |
302
|
|
|
* |
303
|
|
|
* Hard Status: Those concrete values stored in DB |
304
|
|
|
* Soft Status: Those values calculated from stored values in DB |
305
|
|
|
* |
306
|
|
|
* Suggested transitions (Binding is not mandatory) |
307
|
|
|
* Reserved -> Confirmed -> Served |
308
|
|
|
* Reserved -> Served |
309
|
|
|
* Reserved -> Annulated |
310
|
|
|
* Reserved -> Confirmed -> Annulated |
311
|
|
|
* |
312
|
|
|
* Soft Status |
313
|
|
|
* (Active) [ Reserved | Confirmed ] |
314
|
|
|
* (InActive) [ Annulated | Served ] |
315
|
|
|
*/ |
316
|
|
|
|
317
|
|
|
/** |
318
|
|
|
* Determine if is Active. |
319
|
|
|
* |
320
|
|
|
* @return bool |
321
|
|
|
*/ |
322
|
|
|
public function isActive() |
323
|
|
|
{ |
324
|
|
|
return |
325
|
|
|
$this->status == Self::STATUS_CONFIRMED || |
|
|
|
|
326
|
|
|
$this->status == Self::STATUS_RESERVED; |
|
|
|
|
327
|
|
|
} |
328
|
|
|
|
329
|
|
|
/** |
330
|
|
|
* Determine if is Pending. |
331
|
|
|
* |
332
|
|
|
* @return bool |
333
|
|
|
*/ |
334
|
|
|
public function isPending() |
335
|
|
|
{ |
336
|
|
|
return $this->isActive() && $this->isFuture(); |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* Determine if is Future. |
341
|
|
|
* |
342
|
|
|
* @return bool |
343
|
|
|
*/ |
344
|
|
|
public function isFuture() |
345
|
|
|
{ |
346
|
|
|
return !$this->isDue(); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* Determine if is due. |
351
|
|
|
* |
352
|
|
|
* @return bool |
353
|
|
|
*/ |
354
|
|
|
public function isDue() |
355
|
|
|
{ |
356
|
|
|
return $this->start_at->isPast(); |
|
|
|
|
357
|
|
|
} |
358
|
|
|
|
359
|
|
|
//////////// |
360
|
|
|
// Scopes // |
361
|
|
|
//////////// |
362
|
|
|
|
363
|
|
|
///////////////////////// |
364
|
|
|
// Hard Status Scoping // |
365
|
|
|
///////////////////////// |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* Scope to Unarchived Appointments. |
369
|
|
|
* |
370
|
|
|
* @param Illuminate\Database\Query $query |
371
|
|
|
* |
372
|
|
|
* @return Illuminate\Database\Query |
373
|
|
|
*/ |
374
|
|
|
public function scopeUnarchived($query) |
375
|
|
|
{ |
376
|
|
|
return $query |
377
|
|
|
->where(function ($query) { |
378
|
|
|
$query->whereIn('status', [Self::STATUS_RESERVED, Self::STATUS_CONFIRMED]) |
379
|
|
|
->where('start_at', '<=', Carbon::parse('today midnight')->timezone('UTC')) |
380
|
|
|
->orWhere(function ($query) { |
381
|
|
|
$query->where('start_at', '>=', Carbon::parse('today midnight')->timezone('UTC')); |
382
|
|
|
}); |
383
|
|
|
}); |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* Scope to Served Appointments. |
388
|
|
|
* |
389
|
|
|
* @param Illuminate\Database\Query $query |
390
|
|
|
* |
391
|
|
|
* @return Illuminate\Database\Query |
392
|
|
|
*/ |
393
|
|
|
public function scopeServed($query) |
394
|
|
|
{ |
395
|
|
|
return $query->where('status', '=', Self::STATUS_SERVED); |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* Scope to Annulated Appointments. |
400
|
|
|
* |
401
|
|
|
* @param Illuminate\Database\Query $query |
402
|
|
|
* |
403
|
|
|
* @return Illuminate\Database\Query |
404
|
|
|
*/ |
405
|
|
|
public function scopeAnnulated($query) |
406
|
|
|
{ |
407
|
|
|
return $query->where('status', '=', Self::STATUS_ANNULATED); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
///////////////////////// |
411
|
|
|
// Soft Status Scoping // |
412
|
|
|
///////////////////////// |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Scope to not Served Appointments. |
416
|
|
|
* |
417
|
|
|
* @param Illuminate\Database\Query $query |
418
|
|
|
* |
419
|
|
|
* @return Illuminate\Database\Query |
420
|
|
|
*/ |
421
|
|
|
public function scopeUnServed($query) |
422
|
|
|
{ |
423
|
|
|
return $query->where('status', '<>', Self::STATUS_SERVED); |
424
|
|
|
} |
425
|
|
|
|
426
|
|
|
/** |
427
|
|
|
* Scope to Active Appointments. |
428
|
|
|
* |
429
|
|
|
* @param Illuminate\Database\Query $query |
430
|
|
|
* |
431
|
|
|
* @return Illuminate\Database\Query |
432
|
|
|
*/ |
433
|
|
|
public function scopeActive($query) |
434
|
|
|
{ |
435
|
|
|
return $query->whereIn('status', [Self::STATUS_RESERVED, Self::STATUS_CONFIRMED]); |
436
|
|
|
} |
437
|
|
|
|
438
|
|
|
/** |
439
|
|
|
* Scope of Business. |
440
|
|
|
* |
441
|
|
|
* @param Illuminate\Database\Query $query |
442
|
|
|
* @param int $businessId |
443
|
|
|
* |
444
|
|
|
* @return Illuminate\Database\Query |
445
|
|
|
*/ |
446
|
|
|
public function scopeOfBusiness($query, $businessId) |
447
|
|
|
{ |
448
|
|
|
return $query->where('business_id', '=', $businessId); |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
/** |
452
|
|
|
* Scope of date. |
453
|
|
|
* |
454
|
|
|
* @param Illuminate\Database\Query $query |
455
|
|
|
* @param Carbon $date |
456
|
|
|
* |
457
|
|
|
* @return Illuminate\Database\Query |
458
|
|
|
*/ |
459
|
|
|
public function scopeOfDate($query, Carbon $date) |
460
|
|
|
{ |
461
|
|
|
return $query->whereRaw('date(`start_at`) = ?', [$date->timezone('UTC')->toDateString()]); |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
/** |
465
|
|
|
* Scope only future appointments. |
466
|
|
|
* |
467
|
|
|
* @param Illuminate\Database\Query $query |
468
|
|
|
* |
469
|
|
|
* @return Illuminate\Database\Query |
470
|
|
|
*/ |
471
|
|
|
public function scopeFuture($query) |
472
|
|
|
{ |
473
|
|
|
$todayMidnight = Carbon::parse('today midnight')->timezone('UTC'); |
474
|
|
|
|
475
|
|
|
return $query->where('start_at', '>=', $todayMidnight); |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Scope only till date. |
480
|
|
|
* |
481
|
|
|
* @param Illuminate\Database\Query $query |
482
|
|
|
* @param Carbon $date |
483
|
|
|
* |
484
|
|
|
* @return Illuminate\Database\Query |
485
|
|
|
*/ |
486
|
|
|
public function scopeTillDate($query, Carbon $date) |
487
|
|
|
{ |
488
|
|
|
return $query->where('start_at', '<=', $date->timezone('UTC')); |
489
|
|
|
} |
490
|
|
|
|
491
|
|
|
/** |
492
|
|
|
* Between Dates. |
493
|
|
|
* |
494
|
|
|
* @param Illuminate\Database\Query $query |
495
|
|
|
* @param Carbon $startAt |
496
|
|
|
* @param Carbon $finishAt |
497
|
|
|
* |
498
|
|
|
* @return Illuminate\Database\Query |
499
|
|
|
*/ |
500
|
|
|
public function scopeAffectingInterval($query, Carbon $startAt, Carbon $finishAt) |
501
|
|
|
{ |
502
|
|
|
return $query |
503
|
|
|
->where(function ($query) use ($startAt, $finishAt) { |
504
|
|
|
|
505
|
|
View Code Duplication |
$query->where(function ($query) use ($startAt, $finishAt) { |
|
|
|
|
506
|
|
|
$query->where('finish_at', '>=', $finishAt->timezone('UTC')) |
507
|
|
|
->where('start_at', '<=', $startAt->timezone('UTC')); |
508
|
|
|
}) |
509
|
|
View Code Duplication |
->orWhere(function ($query) use ($startAt, $finishAt) { |
|
|
|
|
510
|
|
|
$query->where('finish_at', '<', $finishAt->timezone('UTC')) |
511
|
|
|
->where('finish_at', '>', $startAt->timezone('UTC')); |
512
|
|
|
}) |
513
|
|
View Code Duplication |
->orWhere(function ($query) use ($startAt, $finishAt) { |
|
|
|
|
514
|
|
|
$query->where('start_at', '>', $startAt->timezone('UTC')) |
515
|
|
|
->where('start_at', '<', $finishAt->timezone('UTC')); |
516
|
|
|
}) |
517
|
|
View Code Duplication |
->orWhere(function ($query) use ($startAt, $finishAt) { |
|
|
|
|
518
|
|
|
$query->where('start_at', '>', $startAt->timezone('UTC')) |
519
|
|
|
->where('finish_at', '<', $finishAt->timezone('UTC')); |
520
|
|
|
}); |
521
|
|
|
|
522
|
|
|
}); |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* Determine if the Serve action can be performed. |
527
|
|
|
* |
528
|
|
|
* @return bool |
529
|
|
|
*/ |
530
|
|
|
public function isServeable() |
531
|
|
|
{ |
532
|
|
|
return $this->isActive() && $this->isDue(); |
533
|
|
|
} |
534
|
|
|
|
535
|
|
|
/** |
536
|
|
|
* Determine if the Confirm action can be performed. |
537
|
|
|
* |
538
|
|
|
* @return bool |
539
|
|
|
*/ |
540
|
|
|
public function isConfirmable() |
541
|
|
|
{ |
542
|
|
|
return $this->status == self::STATUS_RESERVED && $this->isFuture(); |
|
|
|
|
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
/** |
546
|
|
|
* Determine if the Annulate action can be performed. |
547
|
|
|
* |
548
|
|
|
* @return bool |
549
|
|
|
*/ |
550
|
|
|
public function isAnnulable() |
551
|
|
|
{ |
552
|
|
|
return $this->isActive(); |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
///////////////////////// |
556
|
|
|
// Hard Status Actions // |
557
|
|
|
///////////////////////// |
558
|
|
|
|
559
|
|
|
/** |
560
|
|
|
* Check and perform Confirm action. |
561
|
|
|
* |
562
|
|
|
* @return $this |
563
|
|
|
*/ |
564
|
|
|
public function doReserve() |
565
|
|
|
{ |
566
|
|
|
if ($this->status === null) { |
|
|
|
|
567
|
|
|
$this->status = self::STATUS_RESERVED; |
|
|
|
|
568
|
|
|
} |
569
|
|
|
|
570
|
|
|
return $this; |
571
|
|
|
} |
572
|
|
|
|
573
|
|
|
/** |
574
|
|
|
* Check and perform Confirm action. |
575
|
|
|
* |
576
|
|
|
* @return $this |
577
|
|
|
*/ |
578
|
|
|
public function doConfirm() |
579
|
|
|
{ |
580
|
|
|
if ($this->isConfirmable()) { |
581
|
|
|
$this->status = self::STATUS_CONFIRMED; |
|
|
|
|
582
|
|
|
|
583
|
|
|
return $this->save(); |
|
|
|
|
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
return $this; |
587
|
|
|
} |
588
|
|
|
|
589
|
|
|
/** |
590
|
|
|
* Check and perform Annulate action. |
591
|
|
|
* |
592
|
|
|
* @return $this |
593
|
|
|
*/ |
594
|
|
|
public function doAnnulate() |
595
|
|
|
{ |
596
|
|
|
if ($this->isAnnulable()) { |
597
|
|
|
$this->status = self::STATUS_ANNULATED; |
|
|
|
|
598
|
|
|
|
599
|
|
|
return $this->save(); |
|
|
|
|
600
|
|
|
} |
601
|
|
|
|
602
|
|
|
return $this; |
603
|
|
|
} |
604
|
|
|
|
605
|
|
|
/** |
606
|
|
|
* Check and perform Serve action. |
607
|
|
|
* |
608
|
|
|
* @return $this |
609
|
|
|
*/ |
610
|
|
|
public function doServe() |
611
|
|
|
{ |
612
|
|
|
if ($this->isServeable()) { |
613
|
|
|
$this->status = self::STATUS_SERVED; |
|
|
|
|
614
|
|
|
|
615
|
|
|
return $this->save(); |
|
|
|
|
616
|
|
|
} |
617
|
|
|
|
618
|
|
|
return $this; |
619
|
|
|
} |
620
|
|
|
} |
621
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.