<?php
namespace App\Entity\Otpusk;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\Otpusk\ImageRepository")
*
* @ORM\Table(
* name="images",
* options={
* "charset":"utf8",
* "engine": "InnoDB"
* },
* indexes={
* @ORM\Index(name="path", columns={"path"}),
* @ORM\Index(name="objectType", columns={"objectId", "objectType", "sort"}),
* @ORM\Index(name="categoryId", columns={"objectType", "categoryId"})
* }
* )
*/
class Image
{
/**
* @var integer
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(name="id", type="integer", length=11, options={"unsigned"=true})
*/
private $id;
/**
* @var integer
* @ORM\Column(name="objectId", type="integer", length=11, options={"fixed":true, "unsigned"=true, "default":NULL}, nullable=true)
*/
private $objectId;
/**
* @var string
* @ORM\Column(name="objectType", type="string", length=15, nullable=true, options={"default":null})
*/
private $objectType;
/**
* @var string
* @ORM\Column(name="path", type="string", length=255)
*/
private $path;
/**
* @var integer
* @ORM\Column(name="width", type="integer", length=11, options={"unsigned"=true})
*/
private $width;
/**
* @var integer
* @ORM\Column(name="height", type="integer", length=11, options={"unsigned"=true})
*/
private $height;
/**
* @var string
* @ORM\Column(name="title", type="string", length=255)
*/
private $title;
/**
* @var string
* @ORM\Column(name="source", type="string", length=255)
*/
private $source;
/**
* @var string
* @ORM\Column(name="options", type="string", length=255)
*/
private $options;
/**
* @var
* @ORM\Column(name="add", type="datetime", options={"default":"CURRENT_TIMESTAMP"}, nullable=false)
*/
private $add;
/**
* @var integer
* @ORM\Column(name="sort", type="smallint", length=2, options={"unsigned"=true, "comment":"сортировка при показе"})
*/
private $sort;
/**
* @var integer
* @ORM\Column(name="sortOld", type="smallint", length=2, options={"unsigned"=true})
*/
private $sortOld;
/**
* @var integer
* @ORM\Column(name="orig", type="smallint", length=1, options={"unsigned"=true, "default":"0", "comment":"Доступен оригинал методом 5"})
*/
private $orig;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\ImagesCategory", inversedBy="images", cascade={"persist"})
* @ORM\JoinColumn(name="categoryId", referencedColumnName="id", nullable=true)
*/
private $category;
/**
* Virtual property to connect images to tHotels
* @ORM\ManyToOne(targetEntity="App\Entity\Otpusk\Hotel", inversedBy="images", cascade={"persist"})
* @ORM\JoinColumn(name="objectId", referencedColumnName="rec_id", nullable=true)
*/
private $hotel;
private $imgUrl = 'https://newimg.otpusk.com/';
private $imgType = '3_otpk';
private $imgSize = '500x375';
/**
* @var \DateTime
*
* @ORM\Column(name="last", type="datetime", nullable=false, options={"default"="CURRENT_TIMESTAMP"})
*/
private $last = 'CURRENT_TIMESTAMP';
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
* @return Image
*/
public function setId(int $id): Image
{
$this->id = $id;
return $this;
}
/**
* @return int
*/
public function getObjectId(): int
{
return $this->objectId;
}
/**
* @param int $objectId
* @return Image
*/
public function setObjectId(int $objectId): Image
{
$this->objectId = $objectId;
return $this;
}
/**
* @return string
*/
public function getObjectType(): string
{
return $this->objectType;
}
/**
* @param string $objectType
* @return Image
*/
public function setObjectType(string $objectType): Image
{
$this->objectType = $objectType;
return $this;
}
/**
* @return string
*/
public function getPath(): string
{
return $this->path;
}
/**
* @param string $path
* @return Image
*/
public function setPath(string $path): Image
{
$this->path = $path;
return $this;
}
/**
* @return int
*/
public function getWidth(): int
{
return $this->width;
}
/**
* @param int $width
* @return Image
*/
public function setWidth(int $width): Image
{
$this->width = $width;
return $this;
}
/**
* @return int
*/
public function getHeight(): int
{
return $this->height;
}
/**
* @param int $height
* @return Image
*/
public function setHeight(int $height): Image
{
$this->height = $height;
return $this;
}
/**
* @return string
*/
public function getTitle(): string
{
return $this->title;
}
/**
* @param string $title
* @return Image
*/
public function setTitle(string $title): Image
{
$this->title = $title;
return $this;
}
/**
* @return string
*/
public function getSource(): string
{
return $this->source;
}
/**
* @param string $source
* @return Image
*/
public function setSource(string $source): Image
{
$this->source = $source;
return $this;
}
/**
* @return string
*/
public function getOptions(): string
{
return $this->options;
}
/**
* @param string $options
* @return Image
*/
public function setOptions(string $options): Image
{
$this->options = $options;
return $this;
}
/**
* @return mixed
*/
public function getAdd()
{
return $this->add;
}
/**
* @param mixed $add
* @return Image
*/
public function setAdd($add)
{
$this->add = $add;
return $this;
}
/**
* @return int
*/
public function getSort(): int
{
return $this->sort;
}
/**
* @param int $sort
* @return Image
*/
public function setSort(int $sort): Image
{
$this->sort = $sort;
return $this;
}
/**
* @return int
*/
public function getSortOld(): int
{
return $this->sortOld;
}
/**
* @param int $sortOld
* @return Image
*/
public function setSortOld(int $sortOld): Image
{
$this->sortOld = $sortOld;
return $this;
}
/**
* @return int
*/
public function getOrig(): int
{
return $this->orig;
}
/**
* @param int $orig
* @return Image
*/
public function setOrig(int $orig): Image
{
$this->orig = $orig;
return $this;
}
public function getCategory(): ?ImagesCategory
{
return $this->category;
}
public function setCategory(?ImagesCategory $category): self
{
$this->category = $category;
return $this;
}
public function getHotel(): ?Hotel
{
return $this->hotel;
}
public function setHotel(?Hotel $hotel): self
{
$this->hotel = $hotel;
return $this;
}
public function getHotelFullName()
{
return $this->hotel->getName() . ' ' . $this->hotel->getStarsNumber() . '☆ (' . $this->hotel->getCity()->getName() . ', ' . $this->hotel->getCity()->getCountry()->getName() . ')';
}
public function getImgUrl()
{
return $this->imgUrl;
}
public function getImgType()
{
return $this->imgType;
}
public function setImgSize($size) {
$this->imgSize = $size;
}
public function getImgSize()
{
return $this->imgSize;
}
public function getImgPath()
{
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';
}
public function getImgFullPath()
{
return $this->getImgUrl() . $this->getImgType() .'/'. $this->getImgSize() . $this->getImgPath();
}
public function getImgBlank()
{
return $this->getImgUrl() .'blank.jpg';
}
public function __toString()
{
return $this->title;
}
}