| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Timegridio\Concierge\Models; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Carbon\Carbon; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Illuminate\Database\Eloquent\Model as EloquentModel; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @property int $id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @property int $business_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @property Illuminate\Support\Collection $business | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * @property int $service_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * @property Timegridio\Concierge\Models\Service $service | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * @property int $humanresource_id | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * @property Timegridio\Concierge\Models\Humanresource $humanresource | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * @property string $date | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @property \Carbon\Carbon $start_at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @property \Carbon\Carbon $finish_at | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @property int $capacity | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 20 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 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() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 | 16 |  |         return $this->belongsTo(Business::class); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 64 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 | 26 |  |         return $this->belongsTo(Service::class); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      * Humanresource. | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |      * @return \Illuminate\Database\Eloquent\Relations\BelongsTo | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 | 18 |  |     public function humanresource() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 | 18 |  |         return $this->belongsTo(Humanresource::class); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 | 10 |  |         return $this->hasMany(Appointment::class); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 94 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |      * Humanresource Slug. | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     public function humanresourceSlug() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         if ($this->humanresource_id) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |             return $this->humanresource->slug; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |         return ''; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 108 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 | 6 |  |         return $query->where('date', '=', $date->toDateString()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 125 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 | 6 |  |         return $query->where('start_at', '<=', $datetime->toDateTimeString()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 | 6 |  |                         ->where('finish_at', '>=', $datetime->toDateTimeString()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 139 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 | 1 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         if (!$since) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |             $since = Carbon::now(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         return $query->where('date', '>', $since); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 156 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         if (!$until) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |             return $query; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |         return $query->where('date', '<', $until); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 173 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 | 2 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 | 2 |  |         return $query->where('service_id', '=', $serviceId); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 186 | 1 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |         $appointments = $this->appointments()->get(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |         foreach ($appointments as $appointment) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             $contact = $appointment->contact()->first(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |             if ($contact->isProfileOf($userId)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |                 return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         return false; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 213 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 | 4 |  |         if ($this->humanresource) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             return intval($this->humanresource->capacity); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 | 4 |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 | 4 |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 | 4 |  |         return intval($this->attributes['capacity']); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 249 | 4 |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 250 | 4 |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 251 | 4 |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 252 | 4 |  |      * has Room. | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  |      * @return bool There is more capacity than used | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |     public function hasRoom() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |         return $this->capacity > $this->appointments()->active()->count(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 259 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 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) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 | 8 |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 | 8 |  |         return $this->capacity > $this->business | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 | 8 |  |                                       ->bookings() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 | 8 |  |                                       ->active() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 | 8 |  |                                       ->affectingInterval($startAt, $finishAt) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 | 8 |  |                                       ->affectingHumanresource($this->humanresource_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |                                       ->count() && | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 | 8 |  |             ($this->start_at <= $startAt && $this->finish_at >= $finishAt); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 275 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 276 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 277 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 278 |  |  |      * Get available capacity between time. | 
            
                                                                        
                            
            
                                    
            
            
                | 279 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 280 |  |  |      * @return int Available capacity | 
            
                                                                        
                            
            
                                    
            
            
                | 281 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     public function getAvailableCapacityBetween(Carbon $startAt, Carbon $finishAt) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |         if (!($this->start_at <= $startAt && $this->finish_at >= $finishAt)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             return 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         $count = $this->business | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |                       ->bookings() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |                       ->active() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |                       ->affectingHumanresource($this->humanresource_id) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |                       ->affectingInterval($startAt, $finishAt) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |                       ->count(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         return $this->capacity - intval($count); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 296 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 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
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.