<?phpnamespace App\Entity;use App\Repository\PartyRepository;use DateTimeInterface;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\DBAL\Types\Types;use Symfony\Component\Validator\Constraints as Asserts;use Doctrine\ORM\Mapping as ORM;use App\Entity\PartyZone;#[ORM\Entity(repositoryClass: PartyRepository::class)]class Party extends Product{ #[Asserts\NotBlank] #[ORM\Column(length: 50)] private ?string $title = null; #[Asserts\NotBlank] #[ORM\Column(type: Types::DATE_MUTABLE)] private ?DateTimeInterface $date = null; #[ORM\ManyToMany(targetEntity: Market::class)] private Collection $markets; #[ORM\Column] private ?bool $hotelStayRequired = null; #[ORM\ManyToMany(targetEntity: HotelRoomTypeArrangement::class)] private Collection $hotelRoomTypeArrangements; #[ORM\ManyToOne] private ?HotelContract $hotelContract = null; #[ORM\Column(type: 'text', nullable: true)] private ?string $description; #[ORM\ManyToOne(targetEntity: City::class)] #[ORM\JoinColumn(name: "city_id", referencedColumnName: "id", nullable: true)] private ?City $city = null; #[ORM\Column(length: 255, nullable: true)] private ?string $address = null; #[ORM\Column(type: 'boolean')] private ?bool $active = true; #[ORM\OneToMany(mappedBy: 'party', targetEntity: PartyZone::class)] private Collection $zones; public function getZones(): Collection { return $this->zones; } public function __construct() { parent::__construct(); $this->markets = new ArrayCollection(); $this->hotelRoomTypeArrangements = new ArrayCollection(); $this->zones = new ArrayCollection(); } public function getTitle(): ?string { return $this->title; } public function setTitle(?string $title): self { $this->title = $title; return $this; } public function getDate(): ?DateTimeInterface { return $this->date; } public function setDate(?DateTimeInterface $date): self { $this->date = $date; return $this; } public function isActive(): ?bool { return $this->active; } public function setActive(bool $active): static { $this->active = $active; return $this; } /** * @return Collection<int, Market> */ public function getMarkets(): Collection { return $this->markets; } public function addMarket(Market $market): self { if (!$this->markets->contains($market)) { $this->markets->add($market); } return $this; } public function removeMarket(Market $market): self { $this->markets->removeElement($market); return $this; } public function isHotelStayRequired(): ?bool { return $this->hotelStayRequired; } public function setHotelStayRequired(bool $hotelStayRequired): self { $this->hotelStayRequired = $hotelStayRequired; return $this; } /** * @return Collection<int, HotelRoomTypeArrangement> */ public function getHotelRoomTypeArrangements(): Collection { return $this->hotelRoomTypeArrangements; } public function addHotelRoomTypeArrangement(HotelRoomTypeArrangement $hotelRoomTypeArrangement): self { if (!$this->hotelRoomTypeArrangements->contains($hotelRoomTypeArrangement)) { $this->hotelRoomTypeArrangements->add($hotelRoomTypeArrangement); } return $this; } public function removeHotelRoomTypeArrangement(HotelRoomTypeArrangement $hotelRoomTypeArrangement): self { $this->hotelRoomTypeArrangements->removeElement($hotelRoomTypeArrangement); return $this; } public function getHotelContract(): ?HotelContract { return $this->hotelContract; } public function setHotelContract(?HotelContract $hotelContract): self { $this->hotelContract = $hotelContract; return $this; } public function __toString(): string { return $this->title ?? ''; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; return $this; } public function getCity(): ?City { return $this->city; } public function setCity(?City $city): static { $this->city = $city; return $this; } public function getAddress(): ?string { return $this->address; } public function setAddress(?string $address): static { $this->address = $address; return $this; } public function getPrimaryImageUrl(): ?string { foreach ($this->getImages() as $image){ if($image->getDisplayOrder()==1){ return $image->getUrl(); } } return null; } public function getClass() : string { return "Party"; } public function getIcon(): string { return "fas fa-glass-cheers"; } public function getMinPriceAdult(): ?float { $minAdultPrice = null; foreach ($this->getZones() as $zones) { $adultPrice = $zones->getAdultSalePrice(); if ($adultPrice !== null && ($minAdultPrice === null || $adultPrice < $minAdultPrice)) { $minAdultPrice = $adultPrice; } } return $minAdultPrice; } public function getMinPriceChild(): ?float { $minChildPrice = null; foreach ($this->getZones() as $zones) { $childPrice = $zones->getChildSalePrice(); if ($childPrice !== null && ($minChildPrice === null || $childPrice < $minChildPrice)) { $minChildPrice = $childPrice; } } return $minChildPrice; }}