Category.php
7 years ago
Extra.php
2 years ago
Package.php
2 years ago
PackageCustomer.php
2 years ago
PackageCustomerService.php
5 years ago
PackageService.php
2 years ago
Resource.php
2 years ago
Service.php
2 years ago
Package.php
294 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\Bookable\Service; |
| 8 | |
| 9 | use AmeliaBooking\Domain\Collection\Collection; |
| 10 | use AmeliaBooking\Domain\Entity\Entities; |
| 11 | use AmeliaBooking\Domain\ValueObjects\BooleanValueObject; |
| 12 | use AmeliaBooking\Domain\ValueObjects\DateTime\DateTimeValue; |
| 13 | use AmeliaBooking\Domain\ValueObjects\DiscountPercentageValue; |
| 14 | use AmeliaBooking\Domain\ValueObjects\Json; |
| 15 | use AmeliaBooking\Domain\ValueObjects\Number\Integer\PositiveInteger; |
| 16 | use AmeliaBooking\Domain\ValueObjects\String\BookableType; |
| 17 | use AmeliaBooking\Domain\ValueObjects\String\Label; |
| 18 | use AmeliaBooking\Domain\ValueObjects\String\Status; |
| 19 | use AmeliaBooking\Domain\Entity\Bookable\AbstractBookable; |
| 20 | |
| 21 | /** |
| 22 | * Class Package |
| 23 | * |
| 24 | * @package AmeliaBooking\Domain\Entity\Bookable\Service |
| 25 | */ |
| 26 | class Package extends AbstractBookable |
| 27 | { |
| 28 | /** @var Collection */ |
| 29 | private $bookable; |
| 30 | |
| 31 | /** @var Collection */ |
| 32 | private $gallery; |
| 33 | |
| 34 | /** @var Status */ |
| 35 | protected $status; |
| 36 | |
| 37 | /** @var BooleanValueObject */ |
| 38 | private $calculatedPrice; |
| 39 | |
| 40 | /** @var DiscountPercentageValue */ |
| 41 | private $discount; |
| 42 | |
| 43 | /** @var DateTimeValue */ |
| 44 | private $endDate; |
| 45 | |
| 46 | /** @var PositiveInteger */ |
| 47 | private $durationCount; |
| 48 | |
| 49 | /** @var Label */ |
| 50 | private $durationType; |
| 51 | |
| 52 | /** @var Json */ |
| 53 | private $translations; |
| 54 | |
| 55 | /** @var BooleanValueObject */ |
| 56 | private $sharedCapacity; |
| 57 | |
| 58 | /** @var PositiveInteger */ |
| 59 | protected $quantity; |
| 60 | |
| 61 | /** @var Json */ |
| 62 | protected $limitPerCustomer; |
| 63 | |
| 64 | |
| 65 | /** |
| 66 | * @return Status |
| 67 | */ |
| 68 | public function getStatus() |
| 69 | { |
| 70 | return $this->status; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @param Status $status |
| 75 | */ |
| 76 | public function setStatus(Status $status) |
| 77 | { |
| 78 | $this->status = $status; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * @return Collection |
| 83 | */ |
| 84 | public function getBookable() |
| 85 | { |
| 86 | return $this->bookable; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @param Collection $bookable |
| 91 | */ |
| 92 | public function setBookable(Collection $bookable) |
| 93 | { |
| 94 | $this->bookable = $bookable; |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * @return Collection |
| 99 | */ |
| 100 | public function getGallery() |
| 101 | { |
| 102 | return $this->gallery; |
| 103 | } |
| 104 | |
| 105 | /** |
| 106 | * @param Collection $gallery |
| 107 | */ |
| 108 | public function setGallery(Collection $gallery) |
| 109 | { |
| 110 | $this->gallery = $gallery; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * @return BooleanValueObject |
| 115 | */ |
| 116 | public function getCalculatedPrice() |
| 117 | { |
| 118 | return $this->calculatedPrice; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * @param BooleanValueObject $calculatedPrice |
| 123 | */ |
| 124 | public function setCalculatedPrice(BooleanValueObject $calculatedPrice) |
| 125 | { |
| 126 | $this->calculatedPrice = $calculatedPrice; |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * @return DiscountPercentageValue |
| 131 | */ |
| 132 | public function getDiscount() |
| 133 | { |
| 134 | return $this->discount; |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * @param DiscountPercentageValue $discount |
| 139 | */ |
| 140 | public function setDiscount(DiscountPercentageValue $discount) |
| 141 | { |
| 142 | $this->discount = $discount; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * @return PositiveInteger |
| 147 | */ |
| 148 | public function getDurationCount() |
| 149 | { |
| 150 | return $this->durationCount; |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * @param PositiveInteger $durationCount |
| 155 | */ |
| 156 | public function setDurationCount(PositiveInteger $durationCount) |
| 157 | { |
| 158 | $this->durationCount = $durationCount; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * @return Label |
| 163 | */ |
| 164 | public function getDurationType() |
| 165 | { |
| 166 | return $this->durationType; |
| 167 | } |
| 168 | |
| 169 | /** |
| 170 | * @param Label $durationType |
| 171 | */ |
| 172 | public function setDurationType(Label $durationType) |
| 173 | { |
| 174 | $this->durationType = $durationType; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * @return DateTimeValue |
| 179 | */ |
| 180 | public function getEndDate() |
| 181 | { |
| 182 | return $this->endDate; |
| 183 | } |
| 184 | |
| 185 | /** |
| 186 | * @param DateTimeValue $endDate |
| 187 | */ |
| 188 | public function setEndDate(DateTimeValue $endDate) |
| 189 | { |
| 190 | $this->endDate = $endDate; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * @return BookableType |
| 195 | */ |
| 196 | public function getType() |
| 197 | { |
| 198 | return new BookableType(Entities::PACKAGE); |
| 199 | } |
| 200 | |
| 201 | |
| 202 | /** |
| 203 | * @return Json |
| 204 | */ |
| 205 | public function getTranslations() |
| 206 | { |
| 207 | return $this->translations; |
| 208 | } |
| 209 | |
| 210 | /** |
| 211 | * @param Json $translations |
| 212 | */ |
| 213 | public function setTranslations(Json $translations) |
| 214 | { |
| 215 | $this->translations = $translations; |
| 216 | } |
| 217 | |
| 218 | /** |
| 219 | * @return BooleanValueObject |
| 220 | */ |
| 221 | public function getSharedCapacity() |
| 222 | { |
| 223 | return $this->sharedCapacity; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * @param BooleanValueObject $sharedCapacity |
| 228 | */ |
| 229 | public function setSharedCapacity(BooleanValueObject $sharedCapacity) |
| 230 | { |
| 231 | $this->sharedCapacity = $sharedCapacity; |
| 232 | } |
| 233 | |
| 234 | /** |
| 235 | * @return PositiveInteger |
| 236 | */ |
| 237 | public function getQuantity() |
| 238 | { |
| 239 | return $this->quantity; |
| 240 | } |
| 241 | |
| 242 | /** |
| 243 | * @param PositiveInteger $quantity |
| 244 | */ |
| 245 | public function setQuantity(PositiveInteger $quantity) |
| 246 | { |
| 247 | $this->quantity = $quantity; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * @return Json |
| 252 | */ |
| 253 | public function getLimitPerCustomer() |
| 254 | { |
| 255 | return $this->limitPerCustomer; |
| 256 | } |
| 257 | |
| 258 | /** |
| 259 | * @param Json $limitPerCustomer |
| 260 | */ |
| 261 | public function setLimitPerCustomer($limitPerCustomer) |
| 262 | { |
| 263 | $this->limitPerCustomer = $limitPerCustomer; |
| 264 | } |
| 265 | |
| 266 | |
| 267 | /** |
| 268 | * @return array |
| 269 | */ |
| 270 | public function toArray() |
| 271 | { |
| 272 | return array_merge( |
| 273 | parent::toArray(), |
| 274 | [ |
| 275 | 'type' => $this->getType()->getValue(), |
| 276 | 'status' => $this->getStatus() ? $this->getStatus()->getValue() : null, |
| 277 | 'gallery' => $this->getGallery() ? $this->getGallery()->toArray() : [], |
| 278 | 'bookable' => $this->getBookable() ? $this->getBookable()->toArray() : [], |
| 279 | 'calculatedPrice' => $this->getCalculatedPrice() ? $this->getCalculatedPrice()->getValue() : null, |
| 280 | 'discount' => $this->getDiscount() ? $this->getDiscount()->getValue() : null, |
| 281 | 'endDate' => $this->getEndDate() ? |
| 282 | $this->getEndDate()->getValue()->format('Y-m-d') . ' 00:00:00' : null, |
| 283 | 'durationCount' => $this->getDurationCount() ? $this->getDurationCount()->getValue() : null, |
| 284 | 'durationType' => $this->getDurationType() ? $this->getDurationType()->getValue() : null, |
| 285 | 'position' => $this->getPosition() ? $this->getPosition()->getValue() : null, |
| 286 | 'translations' => $this->getTranslations() ? $this->getTranslations()->getValue() : null, |
| 287 | 'sharedCapacity' => $this->getSharedCapacity() ? $this->getSharedCapacity()->getValue() : null, |
| 288 | 'quantity' => $this->getQuantity() ? $this->getQuantity()->getValue() : null, |
| 289 | 'limitPerCustomer' => $this->getLimitPerCustomer() ? $this->getLimitPerCustomer()->getValue() : null, |
| 290 | ] |
| 291 | ); |
| 292 | } |
| 293 | } |
| 294 |