src/Entity/Party.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PartyRepository;
  4. use DateTimeInterface;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Symfony\Component\Validator\Constraints as Asserts;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use App\Entity\PartyZone;
  11. #[ORM\Entity(repositoryClassPartyRepository::class)]
  12. class Party extends Product
  13. {
  14.     #[Asserts\NotBlank]
  15.     #[ORM\Column(length50)]
  16.     private ?string $title null;
  17.     #[Asserts\NotBlank]
  18.     #[ORM\Column(typeTypes::DATE_MUTABLE)]
  19.     private ?DateTimeInterface $date null;
  20.     #[ORM\ManyToMany(targetEntityMarket::class)]
  21.     private Collection $markets;
  22.     #[ORM\Column]
  23.     private ?bool $hotelStayRequired null;
  24.     #[ORM\ManyToMany(targetEntityHotelRoomTypeArrangement::class)]
  25.     private Collection $hotelRoomTypeArrangements;
  26.     #[ORM\ManyToOne]
  27.     private ?HotelContract $hotelContract null;
  28.     #[ORM\Column(type'text'nullabletrue)]
  29.     private ?string $description;
  30.     #[ORM\ManyToOne(targetEntityCity::class)]
  31.     #[ORM\JoinColumn(name"city_id"referencedColumnName"id"nullabletrue)]
  32.     private ?City $city null;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $address null;
  35.     #[ORM\Column(type'boolean')]
  36.     private ?bool $active true;
  37.     #[ORM\OneToMany(mappedBy'party'targetEntityPartyZone::class)]
  38.     private Collection $zones;
  39.     public function getZones(): Collection
  40.     {
  41.         return $this->zones;
  42.     }
  43.     public function __construct()
  44.     {
  45.         parent::__construct();
  46.         $this->markets = new ArrayCollection();
  47.         $this->hotelRoomTypeArrangements = new ArrayCollection();
  48.         $this->zones = new ArrayCollection();
  49.     }
  50.     public function getTitle(): ?string
  51.     {
  52.         return $this->title;
  53.     }
  54.     public function setTitle(?string $title): self
  55.     {
  56.         $this->title $title;
  57.         return $this;
  58.     }
  59.     public function getDate(): ?DateTimeInterface
  60.     {
  61.         return $this->date;
  62.     }
  63.     public function setDate(?DateTimeInterface $date): self
  64.     {
  65.         $this->date $date;
  66.         return $this;
  67.     }
  68.     public function isActive(): ?bool
  69.     {
  70.         return $this->active;
  71.     }
  72.     public function setActive(bool $active): static
  73.     {
  74.         $this->active $active;
  75.         return $this;
  76.     }
  77.     /**
  78.      * @return Collection<int, Market>
  79.      */
  80.     public function getMarkets(): Collection
  81.     {
  82.         return $this->markets;
  83.     }
  84.     public function addMarket(Market $market): self
  85.     {
  86.         if (!$this->markets->contains($market)) {
  87.             $this->markets->add($market);
  88.         }
  89.         return $this;
  90.     }
  91.     public function removeMarket(Market $market): self
  92.     {
  93.         $this->markets->removeElement($market);
  94.         return $this;
  95.     }
  96.     public function isHotelStayRequired(): ?bool
  97.     {
  98.         return $this->hotelStayRequired;
  99.     }
  100.     public function setHotelStayRequired(bool $hotelStayRequired): self
  101.     {
  102.         $this->hotelStayRequired $hotelStayRequired;
  103.         return $this;
  104.     }
  105.     /**
  106.      * @return Collection<int, HotelRoomTypeArrangement>
  107.      */
  108.     public function getHotelRoomTypeArrangements(): Collection
  109.     {
  110.         return $this->hotelRoomTypeArrangements;
  111.     }
  112.     public function addHotelRoomTypeArrangement(HotelRoomTypeArrangement $hotelRoomTypeArrangement): self
  113.     {
  114.         if (!$this->hotelRoomTypeArrangements->contains($hotelRoomTypeArrangement)) {
  115.             $this->hotelRoomTypeArrangements->add($hotelRoomTypeArrangement);
  116.         }
  117.         return $this;
  118.     }
  119.     public function removeHotelRoomTypeArrangement(HotelRoomTypeArrangement $hotelRoomTypeArrangement): self
  120.     {
  121.         $this->hotelRoomTypeArrangements->removeElement($hotelRoomTypeArrangement);
  122.         return $this;
  123.     }
  124.     public function getHotelContract(): ?HotelContract
  125.     {
  126.         return $this->hotelContract;
  127.     }
  128.     public function setHotelContract(?HotelContract $hotelContract): self
  129.     {
  130.         $this->hotelContract $hotelContract;
  131.         return $this;
  132.     }
  133.     public function __toString(): string
  134.     {
  135.         return  $this->title  ?? '';
  136.     }
  137.     public function getDescription(): ?string
  138.     {
  139.         return $this->description;
  140.     }
  141.     public function setDescription(?string $description): static
  142.     {
  143.         $this->description $description;
  144.         return $this;
  145.     }
  146.     public function getCity(): ?City
  147.     {
  148.         return $this->city;
  149.     }
  150.     public function setCity(?City $city): static
  151.     {
  152.         $this->city $city;
  153.         return $this;
  154.     }
  155.     public function getAddress(): ?string
  156.     {
  157.         return $this->address;
  158.     }
  159.     public function setAddress(?string $address): static
  160.     {
  161.         $this->address $address;
  162.         return $this;
  163.     }
  164.     public function getPrimaryImageUrl(): ?string
  165.     {
  166.         foreach ($this->getImages() as $image){
  167.             if($image->getDisplayOrder()==1){
  168.                 return $image->getUrl();
  169.             }
  170.         }
  171.         return null;
  172.     }
  173.     public function getClass()  : string {
  174.         return "Party";
  175.     }
  176.     public function getIcon(): string
  177.     {
  178.         return "fas fa-glass-cheers";
  179.     }
  180.     public function getMinPriceAdult(): ?float
  181.     {
  182.         $minAdultPrice null;
  183.         foreach ($this->getZones() as $zones) {
  184.             $adultPrice $zones->getAdultSalePrice();
  185.             if ($adultPrice !== null && ($minAdultPrice === null || $adultPrice $minAdultPrice)) {
  186.                 $minAdultPrice $adultPrice;
  187.             }
  188.         }
  189.         return  $minAdultPrice;
  190.     }
  191.     public function getMinPriceChild(): ?float
  192.     {
  193.         $minChildPrice null;
  194.         foreach ($this->getZones() as $zones) {
  195.             $childPrice $zones->getChildSalePrice();
  196.             if ($childPrice !== null && ($minChildPrice === null || $childPrice $minChildPrice)) {
  197.                 $minChildPrice $childPrice;
  198.             }
  199.         }
  200.         return $minChildPrice;
  201.     }
  202. }