src/Entity/Otpusk/CountryPopular.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Otpusk;
  3. //use App\Application\Sonata\MediaBundle\Entity\Media;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\Otpusk\CountryPopularRepository")
  12.  *
  13.  * @ORM\Table(
  14.  *     name="tCountriesPopular",
  15.  *     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"})},
  16.  *     options={
  17.  *          "charset":"utf8",
  18.  *          "engine": "InnoDB",
  19.  *          "comment":"Горящие туры"
  20.  *     }
  21.  * )
  22.  * @Vich\Uploadable()
  23.  */
  24. class CountryPopular
  25. {
  26.     use TimestampableEntity;
  27.     const TYPES = [
  28.         'Авиа' => 'air',
  29.         'Автобус' => 'bus',
  30.         'Ж/Д' => 'train',
  31.         'Ж/Д - автобус' => 'trainbus',
  32.         'Корабль' => 'ship',
  33.         'Без' => 'no',
  34.     ];
  35.     private $imgFolder '/upload/country/';
  36.     /**
  37.      * @var int
  38.      *
  39.      * @ORM\Column(name="id", type="smallint", nullable=false)
  40.      * @ORM\Id
  41.      * @ORM\GeneratedValue(strategy="AUTO")
  42.      */
  43.     private $id;
  44.     /**
  45.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Country", inversedBy="populars", fetch="EAGER")
  46.      * @ORM\JoinColumn(name="country_id", referencedColumnName="rec_id", nullable=false, onDelete="SET NULL")
  47.      */
  48.     private $country;
  49.     /**
  50.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Market", inversedBy="countryPopulars")
  51.      * @ORM\JoinColumn(name="market_id", referencedColumnName="id", nullable=true, onDelete="CASCADE")
  52.      */
  53.     private $market;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\City", inversedBy="countryPopulars")
  56.      * @ORM\JoinColumn(name="city_id", referencedColumnName="rec_id", nullable=true, onDelete="CASCADE")
  57.      */
  58.     private $city;
  59.     /**
  60.      * @ORM\Column(type="string", type="tCountriesPopularTransport")
  61.      */
  62.     private $transport;
  63.     /**
  64.      * @ORM\Column(type="integer", name="media_id", nullable=true)
  65.      */
  66.     private $image;
  67.     /**
  68.      * @ORM\Column(type="string", length=255, nullable=true)
  69.      */
  70.     private $image2;
  71.     /**
  72.      * @Vich\UploadableField(mapping="country", fileNameProperty="image2")
  73.      */
  74.     private $imageFile;
  75.     /**
  76.      * @ORM\Column(type="boolean")
  77.      */
  78.     private $published true;
  79.     /**
  80.      * @var integer
  81.      * @Gedmo\SortablePosition
  82.      * @ORM\Column(name="position", type="integer")
  83.      */
  84.     private $position;
  85.     private $price null;
  86.     private $priceUah null;
  87.     public function __construct()
  88.     {
  89.         $this->createdAt = new \DateTime();
  90.         $this->updatedAt = new \DateTime();
  91.     }
  92.     public function getId(): ?int
  93.     {
  94.         return $this->id;
  95.     }
  96.     public function getCountry(): ?Country
  97.     {
  98.         return $this->country;
  99.     }
  100.     public function setCountry(?Country $country): self
  101.     {
  102.         $this->country $country;
  103.         return $this;
  104.     }
  105.     public function getMarket(): ?Market
  106.     {
  107.         return $this->market;
  108.     }
  109.     public function setMarket(?Market $market): self
  110.     {
  111.         $this->market $market;
  112.         return $this;
  113.     }
  114.     public function getCity(): ?City
  115.     {
  116.         return $this->city;
  117.     }
  118.     public function setCity(?City $city): self
  119.     {
  120.         $this->city $city;
  121.         return $this;
  122.     }
  123.     public function getTransport(): ?string
  124.     {
  125.         return $this->transport;
  126.     }
  127.     public function setTransport(string $transport): self
  128.     {
  129.         $this->transport $transport;
  130.         return $this;
  131.     }
  132.     public function getPublished(): ?bool
  133.     {
  134.         return $this->published;
  135.     }
  136.     public function setPublished(bool $published): self
  137.     {
  138.         $this->published $published;
  139.         return $this;
  140.     }
  141.     public function getPosition(): ?int
  142.     {
  143.         return $this->position;
  144.     }
  145.     public function setPosition(int $position): self
  146.     {
  147.         $this->position $position;
  148.         return $this;
  149.     }
  150.     public static function getTypes(): ?array
  151.     {
  152.         return self::TYPES;
  153.     }
  154.     public function getTypeName($value): ?string
  155.     {
  156.         return array_search($valueself::TYPES);
  157.     }
  158.     public function getPrice()
  159.     {
  160.         return $this->price;
  161.     }
  162.     public function setPrice($price): void
  163.     {
  164.         $this->price $price;
  165.     }
  166.     public function getPriceUah()
  167.     {
  168.         return $this->priceUah;
  169.     }
  170.     public function setPriceUah($priceUah): void
  171.     {
  172.         $this->priceUah $priceUah;
  173.     }
  174.     public function getImage()
  175.     {
  176.         return $this->image;
  177.     }
  178.     public function setImage($image): void
  179.     {
  180.         $this->image $image;
  181.     }
  182.     /**
  183.      * @return mixed
  184.      */
  185.     public function getImage2()
  186.     {
  187.         return $this->image2;
  188.     }
  189.     /**
  190.      * @param mixed $image2
  191.      */
  192.     public function setImage2($image2): void
  193.     {
  194.         $this->image2 $image2;
  195.     }
  196.     public function getLinkImage()
  197.     {
  198.         return (!is_null($this->getImage2())) ? $this->imgFolder.$this->getImage2() : '#';
  199.     }
  200.     /**
  201.      * @return mixed
  202.      */
  203.     public function getImageFile()
  204.     {
  205.         return $this->imageFile;
  206.     }
  207.     /**
  208.      * @param mixed $imageFile
  209.      */
  210.     public function setImageFile($imageFile null): void
  211.     {
  212.         $this->imageFile $imageFile;
  213.         if ($imageFile) {
  214.             $this->updatedAt = new \DateTime();
  215.         }
  216.     }
  217. }