<?php
namespace App\Entity\Otpusk;
//use App\Application\Sonata\MediaBundle\Entity\Media;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\Otpusk\CountryPopularRepository")
*
* @ORM\Table(
* name="tCountriesPopular",
* uniqueConstraints={@ORM\UniqueConstraint(name="UNIQ_1EAF3EFEEA9FDD75", columns={"media_id"})}, indexes={@ORM\Index(name="position", columns={"position", "published"}), @ORM\Index(name="position_2", columns={"position"}), @ORM\Index(name="published", columns={"published", "position"})},
* options={
* "charset":"utf8",
* "engine": "InnoDB",
* "comment":"Горящие туры"
* }
* )
* @Vich\Uploadable()
*/
class CountryPopular
{
use TimestampableEntity;
const TYPES = [
'Авиа' => 'air',
'Автобус' => 'bus',
'Ж/Д' => 'train',
'Ж/Д - автобус' => 'trainbus',
'Корабль' => 'ship',
'Без' => 'no',
];
private $imgFolder = '/upload/country/';
/**
* @var int
*
* @ORM\Column(name="id", type="smallint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Country", inversedBy="populars", fetch="EAGER")
* @ORM\JoinColumn(name="country_id", referencedColumnName="rec_id", nullable=false, onDelete="SET NULL")
*/
private $country;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Market", inversedBy="countryPopulars")
* @ORM\JoinColumn(name="market_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
*/
private $market;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\City", inversedBy="countryPopulars")
* @ORM\JoinColumn(name="city_id", referencedColumnName="rec_id", nullable=true, onDelete="CASCADE")
*/
private $city;
/**
* @ORM\Column(type="string", type="tCountriesPopularTransport")
*/
private $transport;
/**
* @ORM\Column(type="integer", name="media_id", nullable=true)
*/
private $image;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image2;
/**
* @Vich\UploadableField(mapping="country", fileNameProperty="image2")
*/
private $imageFile;
/**
* @ORM\Column(type="boolean")
*/
private $published = true;
/**
* @var integer
* @Gedmo\SortablePosition
* @ORM\Column(name="position", type="integer")
*/
private $position;
private $price = null;
private $priceUah = null;
public function __construct()
{
$this->createdAt = new \DateTime();
$this->updatedAt = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): self
{
$this->country = $country;
return $this;
}
public function getMarket(): ?Market
{
return $this->market;
}
public function setMarket(?Market $market): self
{
$this->market = $market;
return $this;
}
public function getCity(): ?City
{
return $this->city;
}
public function setCity(?City $city): self
{
$this->city = $city;
return $this;
}
public function getTransport(): ?string
{
return $this->transport;
}
public function setTransport(string $transport): self
{
$this->transport = $transport;
return $this;
}
public function getPublished(): ?bool
{
return $this->published;
}
public function setPublished(bool $published): self
{
$this->published = $published;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}
public static function getTypes(): ?array
{
return self::TYPES;
}
public function getTypeName($value): ?string
{
return array_search($value, self::TYPES);
}
public function getPrice()
{
return $this->price;
}
public function setPrice($price): void
{
$this->price = $price;
}
public function getPriceUah()
{
return $this->priceUah;
}
public function setPriceUah($priceUah): void
{
$this->priceUah = $priceUah;
}
public function getImage()
{
return $this->image;
}
public function setImage($image): void
{
$this->image = $image;
}
/**
* @return mixed
*/
public function getImage2()
{
return $this->image2;
}
/**
* @param mixed $image2
*/
public function setImage2($image2): void
{
$this->image2 = $image2;
}
public function getLinkImage()
{
return (!is_null($this->getImage2())) ? $this->imgFolder.$this->getImage2() : '#';
}
/**
* @return mixed
*/
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param mixed $imageFile
*/
public function setImageFile($imageFile = null): void
{
$this->imageFile = $imageFile;
if ($imageFile) {
$this->updatedAt = new \DateTime();
}
}
}