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