1 | <?php |
||
21 | class Vacancy extends EloquentModel |
||
22 | { |
||
23 | /** |
||
24 | * The attributes that are mass assignable. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $fillable = [ |
||
29 | 'business_id', |
||
30 | 'service_id', |
||
31 | 'humanresource_id', |
||
32 | 'date', |
||
33 | 'start_at', |
||
34 | 'finish_at', |
||
35 | 'capacity', |
||
36 | ]; |
||
37 | |||
38 | /** |
||
39 | * The attributes that aren't mass assignable. |
||
40 | * |
||
41 | * @var array |
||
42 | */ |
||
43 | protected $guarded = ['id']; |
||
44 | |||
45 | /** |
||
46 | * The attributes that should be mutated to dates. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $dates = ['start_at', 'finish_at']; |
||
51 | |||
52 | /////////////////// |
||
53 | // Relationships // |
||
54 | /////////////////// |
||
55 | |||
56 | /** |
||
57 | * belongs to Business. |
||
58 | * |
||
59 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo Relationship Vacancy belongs to Business query |
||
60 | */ |
||
61 | 16 | public function business() |
|
65 | |||
66 | /** |
||
67 | * for Service. |
||
68 | * |
||
69 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo Relationship Vacancy is for providing Service query |
||
70 | */ |
||
71 | 26 | public function service() |
|
75 | |||
76 | /** |
||
77 | * Humanresource. |
||
78 | * |
||
79 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
80 | */ |
||
81 | 18 | public function humanresource() |
|
85 | |||
86 | /** |
||
87 | * holds many Appointments. |
||
88 | * |
||
89 | * @return \Illuminate\Database\Eloquent\Relations\HasMany Relationship Vacancy belongs to Business query |
||
90 | */ |
||
91 | 10 | public function appointments() |
|
95 | |||
96 | /** |
||
97 | * Humanresource Slug. |
||
98 | * |
||
99 | * @return string |
||
100 | */ |
||
101 | public function humanresourceSlug() |
||
109 | |||
110 | //////////// |
||
111 | // Scopes // |
||
112 | //////////// |
||
113 | |||
114 | /** |
||
115 | * Scope For Date. |
||
116 | * |
||
117 | * @param Illuminate\Database\Query $query |
||
118 | * @param Carbon $date Date of inquiry |
||
119 | * |
||
120 | * @return Illuminate\Database\Query Scoped query |
||
121 | */ |
||
122 | 6 | public function scopeForDate($query, Carbon $date) |
|
126 | |||
127 | /** |
||
128 | * Scope For DateTime. |
||
129 | * |
||
130 | * @param Illuminate\Database\Query $query |
||
131 | * @param Carbon $datetime Date and Time of inquiry |
||
132 | * |
||
133 | * @return Illuminate\Database\Query Scoped query |
||
134 | */ |
||
135 | 6 | public function scopeForDateTime($query, Carbon $datetime) |
|
140 | |||
141 | /** |
||
142 | * Scope only Future. |
||
143 | * |
||
144 | * @param Illuminate\Database\Query $query |
||
145 | * @param \Carbon\Carbon $since |
||
146 | * |
||
147 | * @return Illuminate\Database\Query Scoped query |
||
148 | 1 | */ |
|
149 | public function scopeFuture($query, $since = null) |
||
157 | |||
158 | /** |
||
159 | * Scope Until. |
||
160 | * |
||
161 | 14 | * @param Illuminate\Database\Query $query |
|
162 | * @param \Carbon\Carbon $since |
||
|
|||
163 | 14 | * |
|
164 | * @return Illuminate\Database\Query Scoped query |
||
165 | */ |
||
166 | public function scopeUntil($query, $until = null) |
||
174 | |||
175 | /** |
||
176 | * Scope For Service. |
||
177 | * |
||
178 | * @param Illuminate\Database\Query $query |
||
179 | 2 | * @param int serviceId $service Inquired Service to filter |
|
180 | * |
||
181 | 2 | * @return Illuminate\Database\Query Scoped query |
|
182 | */ |
||
183 | 2 | public function scopeForService($query, $serviceId) |
|
187 | |||
188 | 1 | ///////////////////// |
|
189 | // Soft Attributes // |
||
190 | 1 | ///////////////////// |
|
191 | |||
192 | /** |
||
193 | * is Holding Any Appointment for given User. |
||
194 | * |
||
195 | * ToDo: Remove from here as needs knowledge from User |
||
196 | * |
||
197 | * @param int $userId User to check belonging Appointments |
||
198 | * |
||
199 | * @return bool Vacancy holds at least one Appointment of User |
||
200 | */ |
||
201 | public function isHoldingAnyFor($userId) |
||
214 | |||
215 | /** |
||
216 | * is Full. |
||
217 | * |
||
218 | * @return bool Vacancy is fully booked |
||
219 | */ |
||
220 | 17 | # public function isFull() |
|
221 | # { |
||
222 | 17 | # return $this->getFreeSlotsCount() <= 0; |
|
223 | # } |
||
224 | |||
225 | /** |
||
226 | 17 | * get free slots count. |
|
227 | * |
||
228 | * @return int Count Capacity minus Used |
||
229 | */ |
||
230 | # public function getFreeSlotsCount() |
||
231 | # { |
||
232 | # $count = $this->appointments()->active()->count(); |
||
233 | # |
||
234 | 4 | # return $this->capacity - $count; |
|
235 | # } |
||
236 | 4 | ||
237 | /** |
||
238 | * get capacity. |
||
239 | * |
||
240 | * @return int Capacity of the vacancy (in appointment instances) |
||
241 | */ |
||
242 | public function getCapacityAttribute() |
||
250 | 4 | ||
251 | 4 | /** |
|
252 | 4 | * has Room. |
|
253 | * |
||
254 | * @return bool There is more capacity than used |
||
255 | */ |
||
256 | public function hasRoom() |
||
260 | 8 | ||
261 | /** |
||
262 | 8 | * has Room between time. |
|
263 | 7 | * |
|
264 | * @return bool There is more capacity than used |
||
265 | */ |
||
266 | 8 | public function hasRoomBetween(Carbon $startAt, Carbon $finishAt) |
|
276 | |||
277 | /** |
||
278 | * Get available capacity between time. |
||
279 | * |
||
280 | * @return int Available capacity |
||
281 | */ |
||
282 | public function getAvailableCapacityBetween(Carbon $startAt, Carbon $finishAt) |
||
297 | } |
||
298 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.