Appointment.php
442 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @copyright © TMS-Plugins. All rights reserved. |
| 4 | * @licence See LICENCE.md for license details. |
| 5 | */ |
| 6 | |
| 7 | namespace AmeliaBooking\Domain\Entity\Booking\Appointment; |
| 8 | |
| 9 | use AmeliaBooking\Domain\Collection\Collection; |
| 10 | use AmeliaBooking\Domain\Entity\Bookable\Service\Service; |
| 11 | use AmeliaBooking\Domain\Entity\Booking\AbstractBooking; |
| 12 | use AmeliaBooking\Domain\Entity\Entities; |
| 13 | use AmeliaBooking\Domain\Entity\Location\Location; |
| 14 | use AmeliaBooking\Domain\Entity\User\Provider; |
| 15 | use AmeliaBooking\Domain\Entity\Zoom\ZoomMeeting; |
| 16 | use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; |
| 17 | use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; |
| 18 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\Id; |
| 19 | use AmeliaBooking\Domain\ValueObjects\String\BookingType; |
| 20 | use AmeliaBooking\Domain\ValueObjects\String\Label; |
| 21 | use AmeliaBooking\Domain\ValueObjects\String\Token; |
| 22 | |
| 23 | /** |
| 24 | * Class Appointment |
| 25 | * |
| 26 | * @package AmeliaBooking\Domain\Entity\Booking\Appointment |
| 27 | */ |
| 28 | class Appointment extends AbstractBooking |
| 29 | { |
| 30 | /** @var Id */ |
| 31 | private $parentId; |
| 32 | |
| 33 | /** @var Id */ |
| 34 | private $serviceId; |
| 35 | |
| 36 | /** @var Service */ |
| 37 | private $service; |
| 38 | |
| 39 | /** @var Id */ |
| 40 | private $providerId; |
| 41 | |
| 42 | /** @var Provider */ |
| 43 | private $provider; |
| 44 | |
| 45 | /** @var Id */ |
| 46 | private $locationId; |
| 47 | |
| 48 | /** @var Location */ |
| 49 | private $location; |
| 50 | |
| 51 | /** @var Token */ |
| 52 | private $googleCalendarEventId; |
| 53 | |
| 54 | /** @var string */ |
| 55 | private $googleMeetUrl; |
| 56 | |
| 57 | /** @var Label */ |
| 58 | private $outlookCalendarEventId; |
| 59 | |
| 60 | /** @var DateTimeValue */ |
| 61 | protected $bookingStart; |
| 62 | |
| 63 | /** @var DateTimeValue */ |
| 64 | protected $bookingEnd; |
| 65 | |
| 66 | /** @var ZoomMeeting */ |
| 67 | private $zoomMeeting; |
| 68 | |
| 69 | /** @var string */ |
| 70 | private $lessonSpace; |
| 71 | |
| 72 | /** @var Collection */ |
| 73 | private $resources; |
| 74 | |
| 75 | /** @var BooleanValueObject */ |
| 76 | protected $isRescheduled; |
| 77 | |
| 78 | /** @var BooleanValueObject */ |
| 79 | protected $isChangedStatus; |
| 80 | |
| 81 | /** @var BooleanValueObject */ |
| 82 | protected $isFull; |
| 83 | |
| 84 | /** |
| 85 | * Appointment constructor. |
| 86 | * |
| 87 | * @param DateTimeValue $bookingStart |
| 88 | * @param DateTimeValue $bookingEnd |
| 89 | * @param bool $notifyParticipants |
| 90 | * @param Id $serviceId |
| 91 | * @param Id $providerId |
| 92 | */ |
| 93 | public function __construct( |
| 94 | DateTimeValue $bookingStart, |
| 95 | DateTimeValue $bookingEnd, |
| 96 | $notifyParticipants, |
| 97 | Id $serviceId, |
| 98 | Id $providerId |
| 99 | ) { |
| 100 | parent::__construct($notifyParticipants); |
| 101 | |
| 102 | $this->bookingStart = $bookingStart; |
| 103 | |
| 104 | $this->bookingEnd = $bookingEnd; |
| 105 | |
| 106 | $this->serviceId = $serviceId; |
| 107 | |
| 108 | $this->providerId = $providerId; |
| 109 | |
| 110 | $this->resources = new Collection(); |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @return Id |
| 115 | */ |
| 116 | public function getServiceId() |
| 117 | { |
| 118 | return $this->serviceId; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @param Id $serviceId |
| 123 | */ |
| 124 | public function setServiceId(Id $serviceId) |
| 125 | { |
| 126 | $this->serviceId = $serviceId; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @return Service |
| 131 | */ |
| 132 | public function getService() |
| 133 | { |
| 134 | return $this->service; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * @param Service $service |
| 139 | */ |
| 140 | public function setService(Service $service) |
| 141 | { |
| 142 | $this->service = $service; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @return Id |
| 147 | */ |
| 148 | public function getProviderId() |
| 149 | { |
| 150 | return $this->providerId; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @param Id $providerId |
| 155 | */ |
| 156 | public function setProviderId(Id $providerId) |
| 157 | { |
| 158 | $this->providerId = $providerId; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * @return Provider |
| 163 | */ |
| 164 | public function getProvider() |
| 165 | { |
| 166 | return $this->provider; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @param Provider $provider |
| 171 | */ |
| 172 | public function setProvider(Provider $provider) |
| 173 | { |
| 174 | $this->provider = $provider; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * @return Id |
| 179 | */ |
| 180 | public function getLocationId() |
| 181 | { |
| 182 | return $this->locationId; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * @param Id $locationId |
| 187 | */ |
| 188 | public function setLocationId(Id $locationId) |
| 189 | { |
| 190 | $this->locationId = $locationId; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * @return Location |
| 195 | */ |
| 196 | public function getLocation() |
| 197 | { |
| 198 | return $this->location; |
| 199 | } |
| 200 | |
| 201 | /** |
| 202 | * @param Location $location |
| 203 | */ |
| 204 | public function setLocation(Location $location) |
| 205 | { |
| 206 | $this->location = $location; |
| 207 | } |
| 208 | |
| 209 | /** |
| 210 | * @return Token |
| 211 | */ |
| 212 | public function getGoogleCalendarEventId() |
| 213 | { |
| 214 | return $this->googleCalendarEventId; |
| 215 | } |
| 216 | |
| 217 | /** |
| 218 | * @param Token $googleCalendarEventId |
| 219 | */ |
| 220 | public function setGoogleCalendarEventId($googleCalendarEventId) |
| 221 | { |
| 222 | $this->googleCalendarEventId = $googleCalendarEventId; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * @return string |
| 227 | */ |
| 228 | public function getGoogleMeetUrl() |
| 229 | { |
| 230 | return $this->googleMeetUrl; |
| 231 | } |
| 232 | |
| 233 | /** |
| 234 | * @param string $googleMeetUrl |
| 235 | */ |
| 236 | public function setGoogleMeetUrl($googleMeetUrl) |
| 237 | { |
| 238 | $this->googleMeetUrl = $googleMeetUrl; |
| 239 | } |
| 240 | |
| 241 | /** |
| 242 | * @return Label |
| 243 | */ |
| 244 | public function getOutlookCalendarEventId() |
| 245 | { |
| 246 | return $this->outlookCalendarEventId; |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * @param Label $outlookCalendarEventId |
| 251 | */ |
| 252 | public function setOutlookCalendarEventId($outlookCalendarEventId) |
| 253 | { |
| 254 | $this->outlookCalendarEventId = $outlookCalendarEventId; |
| 255 | } |
| 256 | |
| 257 | /** |
| 258 | * @return DateTimeValue |
| 259 | */ |
| 260 | public function getBookingStart() |
| 261 | { |
| 262 | return $this->bookingStart; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * @param DateTimeValue $bookingStart |
| 267 | */ |
| 268 | public function setBookingStart(DateTimeValue $bookingStart) |
| 269 | { |
| 270 | $this->bookingStart = $bookingStart; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * @return DateTimeValue |
| 275 | */ |
| 276 | public function getBookingEnd() |
| 277 | { |
| 278 | return $this->bookingEnd; |
| 279 | } |
| 280 | |
| 281 | /** |
| 282 | * @param DateTimeValue $bookingEnd |
| 283 | */ |
| 284 | public function setBookingEnd(DateTimeValue $bookingEnd) |
| 285 | { |
| 286 | $this->bookingEnd = $bookingEnd; |
| 287 | } |
| 288 | |
| 289 | /** |
| 290 | * @return BookingType |
| 291 | */ |
| 292 | public function getType() |
| 293 | { |
| 294 | return new Bookingtype(Entities::APPOINTMENT); |
| 295 | } |
| 296 | |
| 297 | /** |
| 298 | * @return ZoomMeeting |
| 299 | */ |
| 300 | public function getZoomMeeting() |
| 301 | { |
| 302 | return $this->zoomMeeting; |
| 303 | } |
| 304 | |
| 305 | /** |
| 306 | * @param ZoomMeeting $zoomMeeting |
| 307 | */ |
| 308 | public function setZoomMeeting(ZoomMeeting $zoomMeeting) |
| 309 | { |
| 310 | $this->zoomMeeting = $zoomMeeting; |
| 311 | } |
| 312 | |
| 313 | /** |
| 314 | * @return string |
| 315 | */ |
| 316 | public function getLessonSpace() |
| 317 | { |
| 318 | return $this->lessonSpace; |
| 319 | } |
| 320 | |
| 321 | /** |
| 322 | * @param string $lessonSpace |
| 323 | */ |
| 324 | public function setLessonSpace($lessonSpace) |
| 325 | { |
| 326 | $this->lessonSpace = $lessonSpace; |
| 327 | } |
| 328 | |
| 329 | /** |
| 330 | * @return Id |
| 331 | */ |
| 332 | public function getParentId() |
| 333 | { |
| 334 | return $this->parentId; |
| 335 | } |
| 336 | |
| 337 | /** |
| 338 | * @param Id $parentId |
| 339 | */ |
| 340 | public function setParentId(Id $parentId) |
| 341 | { |
| 342 | $this->parentId = $parentId; |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * @return BooleanValueObject |
| 347 | */ |
| 348 | public function isRescheduled() |
| 349 | { |
| 350 | return $this->isRescheduled; |
| 351 | } |
| 352 | |
| 353 | /** |
| 354 | * @param BooleanValueObject $isRescheduled |
| 355 | */ |
| 356 | public function setRescheduled(BooleanValueObject $isRescheduled) |
| 357 | { |
| 358 | $this->isRescheduled = $isRescheduled; |
| 359 | } |
| 360 | |
| 361 | /** |
| 362 | * @return BooleanValueObject |
| 363 | */ |
| 364 | public function isChangedStatus() |
| 365 | { |
| 366 | return $this->isChangedStatus; |
| 367 | } |
| 368 | |
| 369 | /** |
| 370 | * @param BooleanValueObject $isChangedStatus |
| 371 | */ |
| 372 | public function setChangedStatus(BooleanValueObject $isChangedStatus) |
| 373 | { |
| 374 | $this->isChangedStatus = $isChangedStatus; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * @return BooleanValueObject |
| 379 | */ |
| 380 | public function isFull() |
| 381 | { |
| 382 | return $this->isFull; |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * @param BooleanValueObject $isFull |
| 387 | */ |
| 388 | public function setFull(BooleanValueObject $isFull) |
| 389 | { |
| 390 | $this->isFull = $isFull; |
| 391 | } |
| 392 | |
| 393 | /** |
| 394 | * @return Collection |
| 395 | */ |
| 396 | public function getResources() |
| 397 | { |
| 398 | return $this->resources; |
| 399 | } |
| 400 | |
| 401 | /** |
| 402 | * @param Collection $resources |
| 403 | */ |
| 404 | public function setResources(Collection $resources) |
| 405 | { |
| 406 | $this->resources = $resources; |
| 407 | } |
| 408 | |
| 409 | /** |
| 410 | * @return array |
| 411 | */ |
| 412 | public function toArray() |
| 413 | { |
| 414 | return array_merge( |
| 415 | parent::toArray(), |
| 416 | [ |
| 417 | 'serviceId' => $this->getServiceId()->getValue(), |
| 418 | 'parentId' => $this->getParentId() ? $this->getParentId()->getValue() : null, |
| 419 | 'providerId' => $this->getProviderId()->getValue(), |
| 420 | 'locationId' => null !== $this->getLocationId() ? $this->getLocationId()->getValue() : null, |
| 421 | 'provider' => null !== $this->getProvider() ? $this->getProvider()->toArray() : null, |
| 422 | 'service' => null !== $this->getService() ? $this->getService()->toArray() : null, |
| 423 | 'location' => null !== $this->getLocation() ? $this->getLocation()->toArray() : null, |
| 424 | 'googleCalendarEventId' => null !== $this->getGoogleCalendarEventId() ? |
| 425 | $this->getGoogleCalendarEventId()->getValue() : null, |
| 426 | 'googleMeetUrl' => null !== $this->getGoogleMeetUrl() ? $this->getGoogleMeetUrl() : null, |
| 427 | 'outlookCalendarEventId' => null !== $this->getOutlookCalendarEventId() ? |
| 428 | $this->getOutlookCalendarEventId()->getValue() : null, |
| 429 | 'zoomMeeting' => $this->getZoomMeeting() ? $this->getZoomMeeting()->toArray() : null, |
| 430 | 'lessonSpace' => $this->getLessonSpace() ?: null, |
| 431 | 'bookingStart' => $this->getBookingStart()->getValue()->format('Y-m-d H:i:s'), |
| 432 | 'bookingEnd' => $this->getBookingEnd()->getValue()->format('Y-m-d H:i:s'), |
| 433 | 'type' => $this->getType()->getValue(), |
| 434 | 'isRescheduled' => $this->isRescheduled() ? $this->isRescheduled()->getValue() : null, |
| 435 | 'isChangedStatus' => $this->isChangedStatus() ? $this->isChangedStatus()->getValue() : null, |
| 436 | 'isFull' => $this->isFull() ? $this->isFull()->getValue() : null, |
| 437 | 'resources' => $this->getResources()->toArray(), |
| 438 | ] |
| 439 | ); |
| 440 | } |
| 441 | } |
| 442 |