<?php
namespace App\Entity\Otpusk;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityNotFoundException;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\Otpusk\Geo\BaseObject;
/**
* @ORM\Entity(repositoryClass="App\Repository\Otpusk\HotelRepository")
*
* @ORM\Table(
* name="tHotels",
* options={
* "charset":"utf8",
* "engine": "InnoDB",
* "comment":"Отели"
* },
* uniqueConstraints={@ORM\UniqueConstraint(name="unique", columns={"fCityID", "fTranslit"})},
* indexes={
* @ORM\Index(name="fLastMsgType", columns={"fLastMsgType"}),
* @ORM\Index(name="fName", columns={"fName"}),
* @ORM\Index(name="fTopRate", columns={"fTopRate"}),
* @ORM\Index(name="fLastMsgDate", columns={"fLastMsgDate"}),
* @ORM\Index(name="fStars", columns={"fStars"}),
* @ORM\Index(name="fk_tHotels_1_idx", columns={"chainId"}),
* @ORM\Index(name="fRefsConfirm", columns={"fRefsConfirm"})
* }),
* )
*/
class Hotel extends BaseObject
{
public static $hotelStars = ['one'=>'1*','two'=>'2*','three'=>'3*','four'=>'4*','five'=>'5*','hv1'=>'HV1','hv2'=>'HV2'];
//@ORM\Column(name="lastUpdate", type="datetime", columnDefinition="DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT 'дата последнего обновления информации'", options={"comment":"дата последнего обновления информации"} )
/**
* @var
* @ORM\Column(name="lastUpdate", type="datetime", options={"default":"CURRENT_TIMESTAMP", "comment":"дата последнего обновления информации"}, nullable=false)
*/
private $lastUpdate;
/**
* @var integer
* @ORM\Column(name="fCityID", type="integer", length=6, nullable=true, options={"unsigned":true, "default":NULL})
*/
private $cityId;
/**
* @var string
* @ORM\Column(name="fName", type="string", length=100, options={"fixed":true})
*/
private $name;
/**
* @var string
* @ORM\Column(name="fNameUkr", type="string", length=100)
*/
private $nameUkr;
/**
* @var string
* @ORM\Column(name="fTranslit", type="string", length=100, options={"fixed":true})
*/
private $translit;
/**
* @var string
* @ORM\Column(name="fTranslitRu", type="string", length=500)
*/
private $translitRu;
/**
* @var string
* @ORM\Column(name="fStars", type="tHotelsFStars", nullable=true, options={"default":NULL})
*/
private $stars;
/**
* @var string
* @ORM\Column(name="fStarsAdd", type="tHotelsFStarsAdd", nullable=true, options={"default":NULL})
*/
private $starsAdd;
/**
* @var string
* @ORM\Column(name="fCat", type="tHotelsFCat", options={"default":"city"})
*/
private $cat;
/**
* @var string
* @ORM\Column(name="fBeach", type="tHotelsFBeach", options={"default":"unknown"})
*/
private $beach;
/**
* @var string
* @ORM\Column(name="fForm", type="tHotelsFForm", options={"default":"hotel"})
*/
private $form;
/**
* @var integer
* @ORM\Column(name="fArea", type="integer", length=7, options={"unsigned":true, "comment":"площадь территории"})
*/
private $area;
/**
* @var integer
* @ORM\Column(name="fPriority", type="smallint", length=2, options={"unsigned":true, "comment":"приоритет"})
*/
private $priority;
/**
* @var float
* @ORM\Column(name="fSouthWest", type="decimal", precision=8, scale=5, options={"default":NULL}, nullable=true)
*/
private $southWest;
/**
* @var float
* @ORM\Column(name="fNorthEast", type="decimal", precision=8, scale=5, options={"default":NULL}, nullable=true)
*/
private $northEast;
/**
* @var integer
* @ORM\Column(name="fZoom", type="smallint", length=3, options={"unsigned":true, "default":NULL}, nullable=true)
*/
private $zoom;
/**
* @var boolean
* @ORM\Column(name="fPaid", type="boolean", options={"comment":"платный"})
*/
private $paid;
/**
* @var string
* @ORM\Column(name="fActive", type="tHotelsFActive", options={"default":"new"})
*/
private $active;
/**
* @var
* @ORM\Column(name="fRefsConfirm", type="datetime", nullable=true, options={"default":NULL, "comment":"Проверена актуальность информации"})
*/
private $refsConfirm;
/**
* @var float
* @ORM\Column(name="fRating", type="decimal", precision=7, scale=4, options={"unsigned":true, "default":"0.0000", "comment":"рейтинг отеля на ТурПравде"})
*/
private $rating;
/**
* @var integer
* @ORM\Column(name="fReviews", type="integer", length=5, options={"unsigned":true, "default":0, "comment":"количество отзывов на ТурПравде с оценками"})
*/
private $reviews;
/**
* @var float
* @ORM\Column(name="fTopRate", type="decimal", precision=7, scale=4, options={"unsigned":true,"default":"0.0000", "comment":"интегральная оценка отеля"})
*/
private $topRate;
/**
* @var string
* @ORM\Column(name="fAvgVotes", type="text", options={"comment":"средние оценки отеля по критериям"})
*/
private $avgVotes;
/**
* @var integer
* @ORM\Column(name="fLastMsgType", type="smallint", options={"unsigned":true, "comment":"тип последнего сообщения в админке"})
*/
private $lastMsgType;
/**
* @var
* @ORM\Column(name="fLastMsgDate", type="date", nullable=true, options={"default":NULL, "comment":"дата последнего сообщения в админке"})
*/
private $lastMsgDate;
/**
* @var
* @ORM\Column(name="notFoundVideo", type="datetime", nullable=true, options={"default":NULL})
*/
private $notFoundVideo;
/**
* @var integer
* @ORM\Column(name="people", type="integer", length=11, nullable=true, options={"default":NULL})
*/
private $people;
/**
* @var integer
* @ORM\Column(name="children", type="integer", length=11, nullable=true, options={"default":NULL})
*/
private $children;
/**
* @var integer
* @ORM\Column(name="seniors", type="integer", length=11, nullable=true, options={"default":NULL})
*/
private $seniors;
/**
* @var integer
* @ORM\Column(name="busines", type="integer", length=11, nullable=true, options={"default":NULL})
*/
private $busines;
/**
* @var integer
* @ORM\Column(name="single", type="integer", length=11, nullable=true, options={"default":NULL})
*/
private $single;
/**
* @var City
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\City", inversedBy="hotels")
* @ORM\JoinColumn(name="fCityID", referencedColumnName="rec_id")
*/
private $city;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Chain", inversedBy="hotels")
* @ORM\JoinColumn(name="chainId", referencedColumnName="id")
*/
private $chainId;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Otpusk\HotelsRCache", cascade={"persist", "remove"}, fetch="LAZY")
* @ORM\JoinColumn(name="rec_id", referencedColumnName="id", nullable=true)
*/
private $hotelsRCache;
/**
* @ORM\OneToMany(targetEntity="PriceIndex", mappedBy="hotel")
*/
private $priceIndex;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Otpusk\Image", mappedBy="hotel", cascade={"persist"}, fetch="EAGER")
*/
private $images;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $renovation;
/**
* @ORM\Column(name="fNameEng", type="string", length=128)
*/
private $nameEng;
/**
* @ORM\Column(type="date", options={"comment":"дата последнего получения offer-а"}, nullable=true)
*/
private $lastOfferAt;
/**
* @ORM\Column(name="fAdultAge", type="smallint", nullable=true)
*/
private $adultAge;
/**
* @return City|null
*/
public function getCity(): ?City
{
return $this->city;
}
/**
* @param City|null $city
* @return Hotel
*/
public function setCity(?City $city): Hotel
{
$this->city = $city;
return $this;
}
/**
* @return mixed
*/
public function getLastUpdate()
{
return $this->lastUpdate;
}
/**
* @param mixed $lastUpdate
* @return Hotel
*/
public function setLastUpdate($lastUpdate)
{
$this->lastUpdate = $lastUpdate;
return $this;
}
/**
* @return int
*/
public function getCityId(): int
{
return $this->cityId;
}
/**
* @param int $cityId
* @return Hotel
*/
public function setCityId(int $cityId): Hotel
{
$this->cityId = $cityId;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
if(!$this->name) {
return $this->getId();
}
return $this->name;
}
/**
* @param string $name
* @return Hotel
*/
public function setName(string $name): Hotel
{
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getNameUkr(): string
{
return $this->nameUkr;
}
/**
* @param string $nameUkr
* @return Hotel
*/
public function setNameUkr(string $nameUkr): Hotel
{
$this->nameUkr = $nameUkr;
return $this;
}
/**
* @return string
*/
public function getTranslit(): string
{
return $this->translit;
}
/**
* @param string $translit
* @return Hotel
*/
public function setTranslit(string $translit): Hotel
{
$this->translit = $translit;
return $this;
}
/**
* @return string
*/
public function getTranslitRu(): string
{
return $this->translitRu;
}
/**
* @param string $translitRu
* @return Hotel
*/
public function setTranslitRu(string $translitRu): Hotel
{
$this->translitRu = $translitRu;
return $this;
}
/**
* @return string
*/
public function getStars(): string
{
return $this->stars;
}
/**
* @param string $stars
* @return Hotel
*/
public function setStars(string $stars): Hotel
{
$this->stars = $stars;
return $this;
}
/**
* @return string
*/
public function getStarsAdd(): string
{
return $this->starsAdd;
}
/**
* @param string $starsAdd
* @return Hotel
*/
public function setStarsAdd(string $starsAdd): Hotel
{
$this->starsAdd = $starsAdd;
return $this;
}
public function getAllStars()
{
$stars = $this->getStars();
$additionalStars = $this->getStarsAdd();
if(!empty($additionalStars) && $stars != $additionalStars){
return [$stars, $additionalStars];
}else{
return [$stars];
}
}
/**
* @return string
*/
public function getCat(): string
{
return $this->cat;
}
/**
* @param string $cat
* @return Hotel
*/
public function setCat(string $cat): Hotel
{
$this->cat = $cat;
return $this;
}
/**
* @return string
*/
public function getBeach(): string
{
return $this->beach;
}
/**
* @param string $beach
* @return Hotel
*/
public function setBeach(string $beach): Hotel
{
$this->beach = $beach;
return $this;
}
/**
* @return string
*/
public function getForm(): string
{
return $this->form;
}
/**
* @param string $form
* @return Hotel
*/
public function setForm(string $form): Hotel
{
$this->form = $form;
return $this;
}
/**
* @return int
*/
public function getArea(): int
{
return $this->area;
}
/**
* @param int $area
* @return Hotel
*/
public function setArea(int $area): Hotel
{
$this->area = $area;
return $this;
}
/**
* @return int
*/
public function getPriority(): int
{
return $this->priority;
}
/**
* @param int $priority
* @return Hotel
*/
public function setPriority(int $priority): Hotel
{
$this->priority = $priority;
return $this;
}
/**
* @return float|null
*/
public function getSouthWest(): ?float
{
return $this->southWest;
}
/**
* @param float|null $southWest
* @return Hotel
*/
public function setSouthWest(?float $southWest): Hotel
{
$this->southWest = $southWest;
return $this;
}
/*
*
*/
public function getNorthEast(): ?float
{
return $this->northEast;
}
/**
* @param float|null $northEast
* @return Hotel
*/
public function setNorthEast(?float $northEast): Hotel
{
$this->northEast = $northEast;
return $this;
}
/**
* @return int
*/
public function getZoom(): int
{
return $this->zoom;
}
/**
* @param int $zoom
* @return Hotel
*/
public function setZoom(int $zoom): Hotel
{
$this->zoom = $zoom;
return $this;
}
/**
* @return bool
*/
public function isPaid(): bool
{
return $this->paid;
}
/**
* @param bool $paid
* @return Hotel
*/
public function setPaid(bool $paid): Hotel
{
$this->paid = $paid;
return $this;
}
/**
* @return string
*/
public function getActive(): string
{
return $this->active;
}
/**
* @param string $active
* @return Hotel
*/
public function setActive(string $active): Hotel
{
$this->active = $active;
return $this;
}
/**
* @return mixed
*/
public function getRefsConfirm()
{
return $this->refsConfirm;
}
/**
* @param mixed $refsConfirm
* @return Hotel
*/
public function setRefsConfirm($refsConfirm)
{
$this->refsConfirm = $refsConfirm;
return $this;
}
/**
* @return float
*/
public function getRating(): float
{
return $this->rating;
}
/**
* @param float $rating
* @return Hotel
*/
public function setRating(float $rating): Hotel
{
$this->rating = $rating;
return $this;
}
/**
* @return int
*/
public function getReviews(): int
{
return $this->reviews;
}
/**
* @param int $reviews
* @return Hotel
*/
public function setReviews(int $reviews): Hotel
{
$this->reviews = $reviews;
return $this;
}
/**
* @return float
*/
public function getTopRate(): float
{
return $this->topRate;
}
/**
* @param float $topRate
* @return Hotel
*/
public function setTopRate(float $topRate): Hotel
{
$this->topRate = $topRate;
return $this;
}
/**
* @return string
*/
public function getAvgVotes(): string
{
return $this->avgVotes;
}
/**
* @param string $avgVotes
* @return Hotel
*/
public function setAvgVotes(string $avgVotes): Hotel
{
$this->avgVotes = $avgVotes;
return $this;
}
/**
* @return int
*/
public function getLastMsgType(): int
{
return $this->lastMsgType;
}
/**
* @param int $lastMsgType
* @return Hotel
*/
public function setLastMsgType(int $lastMsgType): Hotel
{
$this->lastMsgType = $lastMsgType;
return $this;
}
/**
* @return mixed
*/
public function getLastMsgDate()
{
return $this->lastMsgDate;
}
/**
* @param mixed $lastMsgDate
* @return Hotel
*/
public function setLastMsgDate($lastMsgDate)
{
$this->lastMsgDate = $lastMsgDate;
return $this;
}
/**
* @return mixed
*/
public function getNotFoundVideo()
{
return $this->notFoundVideo;
}
/**
* @param mixed $notFoundVideo
* @return Hotel
*/
public function setNotFoundVideo($notFoundVideo)
{
$this->notFoundVideo = $notFoundVideo;
return $this;
}
/**
* @return int
*/
public function getPeople(): int
{
return $this->people;
}
/**
* @param int $people
* @return Hotel
*/
public function setPeople(int $people): Hotel
{
$this->people = $people;
return $this;
}
/**
* @return int
*/
public function getChildren(): int
{
return $this->children;
}
/**
* @param int $children
* @return Hotel
*/
public function setChildren(int $children): Hotel
{
$this->children = $children;
return $this;
}
/**
* @return int
*/
public function getSeniors(): int
{
return $this->seniors;
}
/**
* @param int $seniors
* @return Hotel
*/
public function setSeniors(int $seniors): Hotel
{
$this->seniors = $seniors;
return $this;
}
/**
* @return int
*/
public function getBusines(): int
{
return $this->busines;
}
/**
* @param int $busines
* @return Hotel
*/
public function setBusines(int $busines): Hotel
{
$this->busines = $busines;
return $this;
}
/**
* @return int
*/
public function getSingle(): int
{
return $this->single;
}
/**
* @param int $single
* @return Hotel
*/
public function setSingle(int $single): Hotel
{
$this->single = $single;
return $this;
}
public function __toString()
{
return $this->getName().(isset($this->city)?', '.$this->getCity()->getName():'');
}
public static function getStarsLabels(){
return static::$hotelStars;
}
/**
* @ORM\OneToMany(targetEntity="App\Entity\Accounts\Favorites", mappedBy="hotel")
*/
private Collection $favorites;
public function __construct()
{
$this->images = new ArrayCollection();
$this->favorites = new ArrayCollection();
}
public function getFavorites(): Collection
{
return $this->favorites;
}
public function getChainId(): ?Chain
{
return $this->chainId;
}
public function setChainId(?Chain $chainId): self
{
$this->chainId = $chainId;
return $this;
}
public function getHotelsRCache(): ?HotelsRCache
{
return $this->hotelsRCache;
}
public function setHotelsRCache(?HotelsRCache $hotelsRCache): self
{
$this->hotelsRCache = $hotelsRCache;
return $this;
}
public function getTypeWithFriends()
{
try {
return $this->hotelsRCache->getTypeWithFriends();
} catch (EntityNotFoundException $e){
return '';
}
}
public function getTypeRomanticRest()
{
try {
return $this->hotelsRCache->getTypeRomanticRest();
} catch (EntityNotFoundException $e){
return '';
}
}
public function getTypeWithChildren()
{
try {
return $this->hotelsRCache->getTypeWithChildren();
} catch (EntityNotFoundException $e){
return '';
}
}
public function getTypePeacfulRest()
{
try {
return $this->hotelsRCache->getTypePeacfulRest();
} catch (EntityNotFoundException $e){
return '';
}
}
/**
* @return mixed
*/
public function getPriceIndex()
{
return $this->priceIndex;
}
/**
* @param mixed $priceIndex
*/
public function setPriceIndex($priceIndex): void
{
$this->priceIndex = $priceIndex;
}
/**
* @return Collection|Image[]
*/
public function getImages(): Collection
{
// $tmp = new ArrayCollection();
// foreach ($this->images AS $key => $image) {
//// $id = $image->getId();
// $tmp->set($image->getId(), $image);
// }
//// $this->images = $tmp;
//// dd($tmp);
return $this->images;
}
public function addImage(Image $image): self
{
if (!$this->images->contains($image)) {
$this->images[] = $image;
$image->setHotel($this);
}
return $this;
}
public function removeImage(Image $image): self
{
if ($this->images->contains($image)) {
$this->images->removeElement($image);
// set the owning side to null (unless already changed)
if ($image->getHotel() === $this) {
$image->setHotel(null);
}
}
return $this;
}
public function getStarsNumber()
{
$starsNumber = array(
'one' => 1,
'two' => 2,
'three' => 3,
'four' => 4,
'five' => 5,
'h2' => 4,
'h1' => 5,
);
if(array_key_exists($this->stars, $starsNumber))
return $starsNumber[$this->stars];
return '';
}
public function getRenovation(): ?int
{
return $this->renovation;
}
public function setRenovation(?int $renovation): self
{
$this->renovation = $renovation;
return $this;
}
public function getTypeLabel(): string
{
return self::LABEL_HOTEL;
}
public function getNameEng(): ?string
{
return $this->nameEng;
}
public function setNameEng(string $nameEng): self
{
$this->nameEng = $nameEng;
return $this;
}
public function getLastOfferAt(): ?\DateTimeInterface
{
return $this->lastOfferAt;
}
public function setLastOfferAt(?\DateTimeInterface $lastOfferAt): self
{
$this->lastOfferAt = $lastOfferAt;
return $this;
}
public function getAdultAge(): ?int
{
return $this->adultAge;
}
public function setAdultAge(?int $adultAge): self
{
$this->adultAge = $adultAge;
return $this;
}
}