1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Timegridio\Concierge\Presenters; |
4
|
|
|
|
5
|
|
|
use McCool\LaravelAutoPresenter\BasePresenter; |
6
|
|
|
use Timegridio\Concierge\Models\Appointment; |
7
|
|
|
|
8
|
|
|
class AppointmentPresenter extends BasePresenter |
9
|
|
|
{ |
10
|
8 |
|
public function __construct(Appointment $resource) |
11
|
|
|
{ |
12
|
8 |
|
$this->wrappedObject = $resource; |
13
|
8 |
|
} |
14
|
|
|
|
15
|
1 |
|
public function code() |
16
|
|
|
{ |
17
|
1 |
|
$length = $this->wrappedObject->business->pref('appointment_code_length'); |
18
|
|
|
|
19
|
1 |
|
return strtoupper(substr($this->wrappedObject->hash, 0, $length)); |
20
|
|
|
} |
21
|
|
|
|
22
|
3 |
|
public function date($format = 'Y-m-d') |
23
|
|
|
{ |
24
|
3 |
|
if ($this->wrappedObject->start_at->isToday()) { |
25
|
1 |
|
return studly_case(trans('Concierge::appointments.text.today')); |
|
|
|
|
26
|
|
|
} |
27
|
|
|
|
28
|
2 |
|
if ($this->wrappedObject->start_at->isTomorrow()) { |
29
|
1 |
|
return studly_case(trans('Concierge::appointments.text.tomorrow')); |
|
|
|
|
30
|
|
|
} |
31
|
|
|
|
32
|
1 |
|
return $this->wrappedObject |
33
|
1 |
|
->start_at |
34
|
1 |
|
->timezone($this->wrappedObject->business->timezone) |
35
|
1 |
|
->format($format); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
// public function arriveAt() |
|
|
|
|
39
|
|
|
// { |
40
|
|
|
// if (!$this->wrappedObject->business->pref('appointment_flexible_arrival')) { |
41
|
|
|
// return $this->time; |
42
|
|
|
// } |
43
|
|
|
// |
44
|
|
|
// $fromTime = $this->wrappedObject |
45
|
|
|
// ->vacancy |
46
|
|
|
// ->start_at |
47
|
|
|
// ->timezone($this->wrappedObject->business->timezone) |
48
|
|
|
// ->format(config('root.time.format')); |
49
|
|
|
// |
50
|
|
|
// $toTime = $this->wrappedObject |
51
|
|
|
// ->vacancy |
52
|
|
|
// ->finish_at |
53
|
|
|
// ->timezone($this->wrappedObject->business->timezone) |
54
|
|
|
// ->format(config('root.time.format')); |
55
|
|
|
// |
56
|
|
|
// return ucwords(trans('Concierge::appointments.text.from_to', ['from' => $fromTime, 'to' => $toTime])); |
57
|
|
|
// } |
58
|
|
|
|
59
|
|
|
// public function time() |
|
|
|
|
60
|
|
|
// { |
61
|
|
|
// return $this->wrappedObject |
62
|
|
|
// ->start_at |
63
|
|
|
// ->timezone($this->wrappedObject->business->timezone) |
64
|
|
|
// ->format(config('root.time.format')); |
65
|
|
|
// } |
66
|
|
|
|
67
|
|
|
// public function finishTime() |
|
|
|
|
68
|
|
|
// { |
69
|
|
|
// return $this->wrappedObject |
70
|
|
|
// ->finish_at |
71
|
|
|
// ->timezone($this->wrappedObject->business->timezone) |
72
|
|
|
// ->format(config('root.time.format')); |
73
|
|
|
// } |
74
|
|
|
|
75
|
|
|
// public function diffForHumans() |
|
|
|
|
76
|
|
|
// { |
77
|
|
|
// return $this->wrappedObject->start_at->timezone($this->wrappedObject->business->timezone)->diffForHumans(); |
78
|
|
|
// } |
79
|
|
|
|
80
|
1 |
|
public function phone() |
81
|
|
|
{ |
82
|
1 |
|
return $this->wrappedObject->business->phone; |
83
|
|
|
} |
84
|
|
|
|
85
|
1 |
|
public function location() |
86
|
|
|
{ |
87
|
1 |
|
return $this->wrappedObject->business->postal_address; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
// public function statusLetter() |
|
|
|
|
91
|
|
|
// { |
92
|
|
|
// return substr(trans('Concierge::appointments.status.'.$this->wrappedObject->statusLabel), 0, 1); |
93
|
|
|
// } |
94
|
|
|
|
95
|
|
|
// public function status() |
|
|
|
|
96
|
|
|
// { |
97
|
|
|
// return trans('Concierge::appointments.status.'.$this->wrappedObject->statusLabel); |
98
|
|
|
// } |
99
|
|
|
|
100
|
|
|
// public function statusIcon() |
|
|
|
|
101
|
|
|
// { |
102
|
|
|
// return '<span class="label label-'.$this->statusToCssClass().'">'.$this->statusLetter.'</span>'; |
103
|
|
|
// } |
104
|
|
|
|
105
|
1 |
|
public function statusToCssClass() |
106
|
|
|
{ |
107
|
1 |
|
switch ($this->wrappedObject->status) { |
108
|
1 |
|
case Appointment::STATUS_ANNULATED: |
109
|
1 |
|
return 'danger'; |
110
|
|
|
break; |
|
|
|
|
111
|
1 |
|
case Appointment::STATUS_CONFIRMED: |
112
|
1 |
|
return 'success'; |
113
|
|
|
break; |
|
|
|
|
114
|
1 |
|
case Appointment::STATUS_RESERVED: |
115
|
1 |
|
return 'warning'; |
116
|
|
|
break; |
|
|
|
|
117
|
1 |
|
case Appointment::STATUS_SERVED: |
118
|
1 |
|
default: |
119
|
1 |
|
return 'default'; |
120
|
|
|
} |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
// public function panel() |
|
|
|
|
124
|
|
|
// { |
125
|
|
|
// return view('widgets.appointment.panel._body', ['appointment' => $this, 'user' => auth()->user()])->render(); |
126
|
|
|
// } |
127
|
|
|
|
128
|
|
|
// public function row() |
|
|
|
|
129
|
|
|
// { |
130
|
|
|
// return view('widgets.appointment.row._body', ['appointment' => $this, 'user' => auth()->user()])->render(); |
131
|
|
|
// } |
132
|
|
|
} |
133
|
|
|
|
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.