src/Entity/Otpusk/Image.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Otpusk;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * @ORM\Entity(repositoryClass="App\Repository\Otpusk\ImageRepository")
  6.  *
  7.  * @ORM\Table(
  8.  *     name="images",
  9.  *     options={
  10.  *          "charset":"utf8",
  11.  *          "engine": "InnoDB"
  12.  *      },
  13.  *     indexes={
  14.  *          @ORM\Index(name="path", columns={"path"}),
  15.  *          @ORM\Index(name="objectType", columns={"objectId", "objectType", "sort"}),
  16.  *          @ORM\Index(name="categoryId", columns={"objectType", "categoryId"})
  17.  *     }
  18.  * )
  19.  */
  20. class Image
  21. {
  22.     /**
  23.      * @var integer
  24.      * @ORM\Id()
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      * @ORM\Column(name="id", type="integer", length=11, options={"unsigned"=true})
  27.      */
  28.     private $id;
  29.     /**
  30.      * @var integer
  31.      * @ORM\Column(name="objectId", type="integer", length=11, options={"fixed":true, "unsigned"=true, "default":NULL}, nullable=true)
  32.      */
  33.     private $objectId;
  34.     /**
  35.      * @var string
  36.      * @ORM\Column(name="objectType", type="string", length=15, nullable=true, options={"default":null})
  37.      */
  38.     private $objectType;
  39.     /**
  40.      * @var string
  41.      * @ORM\Column(name="path", type="string", length=255)
  42.      */
  43.     private $path;
  44.     /**
  45.      * @var integer
  46.      * @ORM\Column(name="width", type="integer", length=11, options={"unsigned"=true})
  47.      */
  48.     private $width;
  49.     /**
  50.      * @var integer
  51.      * @ORM\Column(name="height", type="integer", length=11, options={"unsigned"=true})
  52.      */
  53.     private $height;
  54.     /**
  55.      * @var string
  56.      * @ORM\Column(name="title", type="string", length=255)
  57.      */
  58.     private $title;
  59.     /**
  60.      * @var string
  61.      * @ORM\Column(name="source", type="string", length=255)
  62.      */
  63.     private $source;
  64.     /**
  65.      * @var string
  66.      * @ORM\Column(name="options", type="string", length=255)
  67.      */
  68.     private $options;
  69.     /**
  70.      * @var
  71.      * @ORM\Column(name="add", type="datetime", options={"default":"CURRENT_TIMESTAMP"}, nullable=false)
  72.      */
  73.     private $add;
  74.     /**
  75.      * @var integer
  76.      * @ORM\Column(name="sort", type="smallint", length=2, options={"unsigned"=true, "comment":"сортировка при показе"})
  77.      */
  78.     private $sort;
  79.     /**
  80.      * @var integer
  81.      * @ORM\Column(name="sortOld", type="smallint", length=2, options={"unsigned"=true})
  82.      */
  83.     private $sortOld;
  84.     /**
  85.      * @var integer
  86.      * @ORM\Column(name="orig", type="smallint", length=1, options={"unsigned"=true, "default":"0", "comment":"Доступен оригинал методом 5"})
  87.      */
  88.     private $orig;
  89.     /**
  90.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\ImagesCategory", inversedBy="images", cascade={"persist"})
  91.      * @ORM\JoinColumn(name="categoryId", referencedColumnName="id", nullable=true)
  92.      */
  93.     private $category;
  94.     /**
  95.      * Virtual property to connect images to tHotels
  96.      * @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Hotel", inversedBy="images", cascade={"persist"})
  97.      * @ORM\JoinColumn(name="objectId", referencedColumnName="rec_id", nullable=true)
  98.      */
  99.     private $hotel;
  100.     private $imgUrl 'https://newimg.otpusk.com/';
  101.     private $imgType '3_otpk';
  102.     private $imgSize '500x375';
  103.     /**
  104.      * @var \DateTime
  105.      *
  106.      * @ORM\Column(name="last", type="datetime", nullable=false, options={"default"="CURRENT_TIMESTAMP"})
  107.      */
  108.     private $last 'CURRENT_TIMESTAMP';
  109.     /**
  110.      * @return int
  111.      */
  112.     public function getId(): int
  113.     {
  114.         return $this->id;
  115.     }
  116.     /**
  117.      * @param int $id
  118.      * @return Image
  119.      */
  120.     public function setId(int $id): Image
  121.     {
  122.         $this->id $id;
  123.         return $this;
  124.     }
  125.     /**
  126.      * @return int
  127.      */
  128.     public function getObjectId(): int
  129.     {
  130.         return $this->objectId;
  131.     }
  132.     /**
  133.      * @param int $objectId
  134.      * @return Image
  135.      */
  136.     public function setObjectId(int $objectId): Image
  137.     {
  138.         $this->objectId $objectId;
  139.         return $this;
  140.     }
  141.     /**
  142.      * @return string
  143.      */
  144.     public function getObjectType(): string
  145.     {
  146.         return $this->objectType;
  147.     }
  148.     /**
  149.      * @param string $objectType
  150.      * @return Image
  151.      */
  152.     public function setObjectType(string $objectType): Image
  153.     {
  154.         $this->objectType $objectType;
  155.         return $this;
  156.     }
  157.     /**
  158.      * @return string
  159.      */
  160.     public function getPath(): string
  161.     {
  162.         return $this->path;
  163.     }
  164.     /**
  165.      * @param string $path
  166.      * @return Image
  167.      */
  168.     public function setPath(string $path): Image
  169.     {
  170.         $this->path $path;
  171.         return $this;
  172.     }
  173.     /**
  174.      * @return int
  175.      */
  176.     public function getWidth(): int
  177.     {
  178.         return $this->width;
  179.     }
  180.     /**
  181.      * @param int $width
  182.      * @return Image
  183.      */
  184.     public function setWidth(int $width): Image
  185.     {
  186.         $this->width $width;
  187.         return $this;
  188.     }
  189.     /**
  190.      * @return int
  191.      */
  192.     public function getHeight(): int
  193.     {
  194.         return $this->height;
  195.     }
  196.     /**
  197.      * @param int $height
  198.      * @return Image
  199.      */
  200.     public function setHeight(int $height): Image
  201.     {
  202.         $this->height $height;
  203.         return $this;
  204.     }
  205.     /**
  206.      * @return string
  207.      */
  208.     public function getTitle(): string
  209.     {
  210.         return $this->title;
  211.     }
  212.     /**
  213.      * @param string $title
  214.      * @return Image
  215.      */
  216.     public function setTitle(string $title): Image
  217.     {
  218.         $this->title $title;
  219.         return $this;
  220.     }
  221.     /**
  222.      * @return string
  223.      */
  224.     public function getSource(): string
  225.     {
  226.         return $this->source;
  227.     }
  228.     /**
  229.      * @param string $source
  230.      * @return Image
  231.      */
  232.     public function setSource(string $source): Image
  233.     {
  234.         $this->source $source;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return string
  239.      */
  240.     public function getOptions(): string
  241.     {
  242.         return $this->options;
  243.     }
  244.     /**
  245.      * @param string $options
  246.      * @return Image
  247.      */
  248.     public function setOptions(string $options): Image
  249.     {
  250.         $this->options $options;
  251.         return $this;
  252.     }
  253.     /**
  254.      * @return mixed
  255.      */
  256.     public function getAdd()
  257.     {
  258.         return $this->add;
  259.     }
  260.     /**
  261.      * @param mixed $add
  262.      * @return Image
  263.      */
  264.     public function setAdd($add)
  265.     {
  266.         $this->add $add;
  267.         return $this;
  268.     }
  269.     /**
  270.      * @return int
  271.      */
  272.     public function getSort(): int
  273.     {
  274.         return $this->sort;
  275.     }
  276.     /**
  277.      * @param int $sort
  278.      * @return Image
  279.      */
  280.     public function setSort(int $sort): Image
  281.     {
  282.         $this->sort $sort;
  283.         return $this;
  284.     }
  285.     /**
  286.      * @return int
  287.      */
  288.     public function getSortOld(): int
  289.     {
  290.         return $this->sortOld;
  291.     }
  292.     /**
  293.      * @param int $sortOld
  294.      * @return Image
  295.      */
  296.     public function setSortOld(int $sortOld): Image
  297.     {
  298.         $this->sortOld $sortOld;
  299.         return $this;
  300.     }
  301.     /**
  302.      * @return int
  303.      */
  304.     public function getOrig(): int
  305.     {
  306.         return $this->orig;
  307.     }
  308.     /**
  309.      * @param int $orig
  310.      * @return Image
  311.      */
  312.     public function setOrig(int $orig): Image
  313.     {
  314.         $this->orig $orig;
  315.         return $this;
  316.     }
  317.     public function getCategory(): ?ImagesCategory
  318.     {
  319.         return $this->category;
  320.     }
  321.     public function setCategory(?ImagesCategory $category): self
  322.     {
  323.         $this->category $category;
  324.         return $this;
  325.     }
  326.     public function getHotel(): ?Hotel
  327.     {
  328.         return $this->hotel;
  329.     }
  330.     public function setHotel(?Hotel $hotel): self
  331.     {
  332.         $this->hotel $hotel;
  333.         return $this;
  334.     }
  335.     public function getHotelFullName()
  336.     {
  337.         return $this->hotel->getName() . ' ' $this->hotel->getStarsNumber() . '☆ (' $this->hotel->getCity()->getName() . ', ' $this->hotel->getCity()->getCountry()->getName() . ')';
  338.     }
  339.     public function getImgUrl()
  340.     {
  341.         return $this->imgUrl;
  342.     }
  343.     public function getImgType()
  344.     {
  345.         return $this->imgType;
  346.     }
  347.     public function setImgSize($size) {
  348.         $this->imgSize $size;
  349.     }
  350.     public function getImgSize()
  351.     {
  352.         return $this->imgSize;
  353.     }
  354.     public function getImgPath()
  355.     {
  356.         return '/'sprintf("%02d/%02d/%02d/%02d/", ($this->id 100000000) % 100, ($this->id 1000000) % 100, ($this->id 10000) % 100, ($this->id 100) % 100) . $this->id '.webp';
  357.     }
  358.     public function getImgFullPath()
  359.     {
  360.         return $this->getImgUrl() . $this->getImgType() .'/'$this->getImgSize() . $this->getImgPath();
  361.     }
  362.     public function getImgBlank()
  363.     {
  364.         return $this->getImgUrl() .'blank.jpg';
  365.     }
  366.     public function __toString()
  367.     {
  368.         return $this->title;
  369.     }
  370. }