<?php
namespace App\Realty\Entity;
use App\Base\Annotation\Orm\Help;
use App\Base\Annotation\Orm\Label;
use App\Base\Annotation\Orm\NonEditable;
use App\Base\Annotation\Orm\UploadableColumn;
use App\Base\Entity\UploadableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
use App\Realty\Repository\LayoutRepository;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: LayoutRepository::class)]
#[Vich\Uploadable]
class Layout
{
use UploadableTrait;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
protected int|null $id;
#[ORM\Column(type: 'string', length: 255)]
#[Label('Ключ для синхронизации')]
private string $outerKey = '';
#[ORM\Column(type: 'string', length: 255)]
#[Label('Краткое наименование')]
private string $name = '';
// + площадь кухни + еще что-нибудь
#[ORM\Column(type: 'string', length: 255)]
#[Label('Полное наименование')]
private string $fullName = '';
#[ORM\Column(type: 'string', length: 255)]
#[Label('Краткое наименование')]
private string $type = '';
#[ORM\Column(type: 'integer')]
#[Label('Кол-во комнат')]
private int $rooms = 0;
#[ORM\Column(type: 'boolean')]
#[Label('Студия')]
private bool $isStudio = false;
#[ORM\Column(type: 'float')]
#[Label('Общая площадь')]
private float $areaTotal = 0;
#[ORM\Column(type: 'float', nullable: true)]
#[Label('Жилая площадь')]
private float|null $areaLiving = null;
#[ORM\Column(type: 'float', nullable: true)]
#[Label('Кухни площадь')]
private float|null $areaKitchen = null;
#[ORM\ManyToOne(targetEntity: Building::class, inversedBy: 'layouts')]
#[ORM\JoinColumn(nullable: true)]
#[Label('Здание')]
private ?Building $building = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[NonEditable]
#[Label('Доступна на этажах')]
private ?string $floorsVerbose = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[NonEditable]
#[Label('Доступные отделки')]
private ?string $renovationsVerbose = null;
#[ORM\Column(type: 'integer', nullable: true)]
#[NonEditable]
#[Label('Цена')]
#[Help('Значение цены "от"')]
private int|null $price = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[NonEditable]
#[Label('Артикул')]
private ?string $article = null;
#[ORM\Column(type: 'datetime', nullable: true)]
#[Label('Дата последней синхронизации')]
protected \DateTime|null $lastSyncAt = null;
#[Vich\UploadableField(mapping: 'uploads', fileNameProperty: 'imageName')]
protected File|null $imageFile = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[UploadableColumn]
protected string|null $imageName = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
protected string|null $imageHash = null;
#[ORM\Column(type: 'string', length: 255, unique: true, nullable: true)]
#[Gedmo\Slug(fields: ['fullName'], updatable: false, unique: true)]
#[Help('URL')]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'layout', targetEntity: Apartment::class, orphanRemoval: true)]
private $apartments;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[NonEditable]
#[Label('Секция')]
private ?string $section = null;
#[ORM\ManyToMany(targetEntity: FloorGroupPlace::class, inversedBy: 'layouts')]
#[Label('Группа этажей')]
private Collection $floorGroopPlaces;
#[Vich\UploadableField(mapping: 'uploads', fileNameProperty: 'imagePlanName')]
#[Label('Изображение плана этажа')]
protected File|null $imagePlanFile = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[UploadableColumn]
protected string|null $imagePlanName = null;
// Не забудь в классе
// use UploadableTrait;
#[Vich\UploadableField(mapping: 'uploads', fileNameProperty: 'imageFurnitureName')]
#[Label('Изображение планировки с мебелью')]
protected File|null $imageFurnitureFile = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[UploadableColumn]
protected string|null $imageFurnitureName = null;
#[ORM\Column(length: 255, nullable: true)]
#[Label('Название акции')]
private ?string $actionName = 'Акция';
#[ORM\Column(length: 255, nullable: true)]
#[Label('Ссылка на акцию на карточке квартиры')]
#[Help('Необходимо использовать полную ссылку')]
private ?string $url = '';
#[ORM\Column(length: 255, nullable: true)]
#[Label('Текст внутри подсказки')]
private ?string $actionHintText = '';
#[ORM\Column(type: 'string', length: 255, nullable: true)]
#[Label('Цвет фона иконки')]
protected string|null $iconBg = '#8095D3';
#[Vich\UploadableField(mapping: 'uploads', fileNameProperty: 'imageIconName')]
#[Label('Файл .svg')]
#[Help('Размер 18x18 px')]
protected File|null $imageIconFile = null;
#[ORM\Column(type: 'string', length: 255)]
#[UploadableColumn]
protected string|null $imageIconName = '';
#[ORM\Column(type: 'boolean')]
#[Label('Показывать акцию')]
protected bool $active = false;
public function __construct()
{
$this->apartments = new ArrayCollection();
$this->floorGroopPlaces = new ArrayCollection();
}
public function getBuilding(): ?Building
{
return $this->building;
}
public function setBuilding(?Building $building): self
{
$this->building = $building;
return $this;
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @param int|null $id
* @return Layout
*/
public function setId(?int $id): Layout
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getOuterKey(): string
{
return $this->outerKey;
}
/**
* @param string $outerKey
* @return Layout
*/
public function setOuterKey(string $outerKey): Layout
{
$this->outerKey = $outerKey;
return $this;
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
* @return Layout
*/
public function setName(string $name): Layout
{
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getFullName(): string
{
return $this->fullName;
}
/**
* @param string $fullName
* @return Layout
*/
public function setFullName(string $fullName): Layout
{
$this->fullName = $fullName;
return $this;
}
/**
* @return int
*/
public function getRooms(): int
{
return $this->rooms;
}
/**
* @param int $rooms
* @return Layout
*/
public function setRooms(int $rooms): Layout
{
$this->rooms = $rooms;
return $this;
}
/**
* @return bool
*/
public function isStudio(): bool
{
return $this->isStudio;
}
/**
* @param bool $isStudio
* @return Layout
*/
public function setIsStudio(bool $isStudio): Layout
{
$this->isStudio = $isStudio;
return $this;
}
/**
* @return float|int
*/
public function getAreaTotal(): float|int
{
return $this->areaTotal;
}
/**
* @param float|int $areaTotal
* @return Layout
*/
public function setAreaTotal(float|int $areaTotal): Layout
{
$this->areaTotal = $areaTotal;
return $this;
}
/**
* @return float|null
*/
public function getAreaLiving(): ?float
{
return $this->areaLiving;
}
/**
* @param float|null $areaLiving
* @return Layout
*/
public function setAreaLiving(?float $areaLiving): Layout
{
$this->areaLiving = $areaLiving;
return $this;
}
/**
* @return float|null
*/
public function getAreaKitchen(): ?float
{
return $this->areaKitchen;
}
/**
* @param float|null $areaKitchen
* @return Layout
*/
public function setAreaKitchen(?float $areaKitchen): Layout
{
$this->areaKitchen = $areaKitchen;
return $this;
}
/**
* @return \DateTime|null
*/
public function getLastSyncAt(): ?\DateTime
{
return $this->lastSyncAt;
}
/**
* @param \DateTime|null $lastSyncAt
* @return Layout
*/
public function setLastSyncAt(?\DateTime $lastSyncAt): Layout
{
$this->lastSyncAt = $lastSyncAt;
return $this;
}
public function __toString(): string
{
$name = [];
if ($this->getBuilding()) {
$name[] = (string) $this->getBuilding();
}
$name[] = $this->getName();
if ($this->getFloorsVerbose()) {
$name[] = "({$this->getFloorsVerbose()} этаж.)";
}
if ($this->getOuterKey()) {
$name[] = "id: {$this->getOuterKey()}";
}
return implode(' - ', $name);
}
public function getImageHash(): ?string
{
return $this->imageHash;
}
public function setImageHash(?string $imageHash): void
{
$this->imageHash = $imageHash;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): void
{
$this->slug = $slug;
}
/**
* @return Collection<int, Apartment>
*/
public function getApartments(): Collection
{
return $this->apartments;
}
public function addApartment(Apartment $apartment): self
{
if (!$this->apartments->contains($apartment)) {
$this->apartments[] = $apartment;
$apartment->setLayout($this);
}
return $this;
}
public function removeApartment(Apartment $apartment): self
{
if ($this->apartments->removeElement($apartment)) {
// set the owning side to null (unless already changed)
if ($apartment->getLayout() === $this) {
$apartment->setLayout(null);
}
}
return $this;
}
public function getType(): string
{
return $this->type;
}
public function setType(string $type): void
{
$this->type = $type;
}
public function getFloorsVerbose(): ?string
{
return $this->floorsVerbose;
}
public function setFloorsVerbose(?string $floorsVerbose): void
{
$this->floorsVerbose = $floorsVerbose;
}
public function getPrice(): ?int
{
return $this->price;
}
public function setPrice(?int $price): void
{
$this->price = $price;
}
public function getRenovationsVerbose(): ?string
{
return $this->renovationsVerbose;
}
public function setRenovationsVerbose(?string $renovationsVerbose): void
{
$this->renovationsVerbose = $renovationsVerbose;
}
/**
* @return Collection<int, FloorGroupPlace>
*/
public function getFloorGroopPlaces(): Collection
{
return $this->floorGroopPlaces;
}
public function addFloorGroopPlace(FloorGroupPlace $floorGroopPlace): self
{
if (!$this->floorGroopPlaces->contains($floorGroopPlace)) {
$this->floorGroopPlaces->add($floorGroopPlace);
}
return $this;
}
public function removeFloorGroopPlace(FloorGroupPlace $floorGroopPlace): self
{
$this->floorGroopPlaces->removeElement($floorGroopPlace);
return $this;
}
public function getSection(): ?string
{
return $this->section;
}
public function setSection(?string $section): void
{
$this->section = $section;
}
public function getArticle(): ?string
{
return $this->article;
}
public function setArticle(?string $article): void
{
$this->article = $article;
}
public function getActionName(): ?string
{
return $this->actionName;
}
public function setActionName(?string $actionName): void
{
$this->actionName = $actionName;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): void
{
$this->url = $url;
}
public function getActionHintText(): ?string
{
return $this->actionHintText;
}
public function setActionHintText(?string $actionHintText): void
{
$this->actionHintText = $actionHintText;
}
public function getIconBg(): ?string
{
return $this->iconBg;
}
public function setIconBg(?string $iconBg): void
{
$this->iconBg = $iconBg;
}
public function isActive(): bool
{
return $this->active;
}
public function setActive(bool $active): void
{
$this->active = $active;
}
}