1 | <?php |
||
12 | class Vacancy extends EloquentModel |
||
13 | { |
||
14 | /** |
||
15 | * The attributes that are mass assignable. |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected $fillable = ['business_id', 'service_id', 'date', 'start_at', 'finish_at', 'capacity']; |
||
20 | |||
21 | /** |
||
22 | * The attributes that aren't mass assignable. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $guarded = ['id']; |
||
27 | |||
28 | /** |
||
29 | * The attributes that should be mutated to dates. |
||
30 | * |
||
31 | * @var array |
||
32 | */ |
||
33 | protected $dates = ['start_at', 'finish_at']; |
||
34 | |||
35 | /////////////////// |
||
36 | // Relationships // |
||
37 | /////////////////// |
||
38 | |||
39 | /** |
||
40 | * belongs to Business. |
||
41 | * |
||
42 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo Relationship Vacancy belongs to Business query |
||
43 | */ |
||
44 | 12 | public function business() |
|
48 | |||
49 | /** |
||
50 | * for Service. |
||
51 | * |
||
52 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo Relationship Vacancy is for providing Service query |
||
53 | */ |
||
54 | 12 | public function service() |
|
58 | |||
59 | /** |
||
60 | * holds many Appointments. |
||
61 | * |
||
62 | * @return \Illuminate\Database\Eloquent\Relations\HasMany Relationship Vacancy belongs to Business query |
||
63 | */ |
||
64 | 12 | public function appointments() |
|
68 | |||
69 | //////////// |
||
70 | // Scopes // |
||
71 | //////////// |
||
72 | |||
73 | /** |
||
74 | * Scope For Date. |
||
75 | * |
||
76 | * @param Illuminate\Database\Query $query |
||
77 | * @param Carbon $date Date of inquiry |
||
78 | * |
||
79 | * @return Illuminate\Database\Query Scoped query |
||
80 | */ |
||
81 | 4 | public function scopeForDate($query, Carbon $date) |
|
85 | |||
86 | /** |
||
87 | * Scope For DateTime. |
||
88 | * |
||
89 | * @param Illuminate\Database\Query $query |
||
90 | * @param Carbon $datetime Date and Time of inquiry |
||
91 | * |
||
92 | * @return Illuminate\Database\Query Scoped query |
||
93 | */ |
||
94 | 6 | public function scopeForDateTime($query, Carbon $datetime) |
|
99 | |||
100 | /** |
||
101 | * Scope For Service. |
||
102 | * |
||
103 | * @param Illuminate\Database\Query $query |
||
104 | * @param int serviceId $service Inquired Service to filter |
||
105 | * |
||
106 | * @return Illuminate\Database\Query Scoped query |
||
107 | */ |
||
108 | 12 | public function scopeForService($query, $serviceId) |
|
112 | |||
113 | ///////////////////// |
||
114 | // Soft Attributes // |
||
115 | ///////////////////// |
||
116 | |||
117 | /** |
||
118 | * is Holding Any Appointment for given User. |
||
119 | * |
||
120 | * ToDo: Remove from here as needs knowledge from User |
||
121 | * |
||
122 | * @param int $userId User to check belonging Appointments |
||
123 | * |
||
124 | * @return bool Vacancy holds at least one Appointment of User |
||
125 | */ |
||
126 | 2 | public function isHoldingAnyFor($userId) |
|
139 | |||
140 | /** |
||
141 | * get capacity. |
||
142 | * |
||
143 | * @return int Capacity of the vacancy (in appointment instances) |
||
144 | */ |
||
145 | 12 | public function getCapacityAttribute() |
|
149 | |||
150 | /** |
||
151 | * has Room. |
||
152 | * |
||
153 | * @return bool There is more capacity than used |
||
154 | */ |
||
155 | 4 | public function hasRoom() |
|
159 | |||
160 | /** |
||
161 | * has Room between time. |
||
162 | * |
||
163 | * @return bool There is more capacity than used |
||
164 | */ |
||
165 | 2 | public function hasRoomBetween(Carbon $startAt, Carbon $finishAt) |
|
173 | |||
174 | /** |
||
175 | * Get available capacity between time. |
||
176 | * |
||
177 | * @return int Available capacity |
||
178 | */ |
||
179 | 6 | public function getAvailableCapacityBetween(Carbon $startAt, Carbon $finishAt) |
|
189 | } |
||
190 |
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.