<?php
namespace App\Entity;
use App\Repository\FileDataRepository;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: FileDataRepository::class)]
class FileData
{
public const IMAGE_NOT_AVAILABLE_PATH = "/uploads/image_not_available.webp";
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 128)]
private ?string $name;
#[ORM\Column(type: 'string', length: 128)]
private ?string $directoryPath;
#[ORM\Column(type: 'string', length: 32)]
private ?string $extension;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $alt;
#[ORM\ManyToOne(targetEntity: Provider::class, inversedBy: 'images')]
private ?Provider $provider;
#[ORM\Column(type: 'smallint', nullable: true)]
private mixed $displayOrder;
#[ORM\Column(length: 255, nullable: true)]
private ?string $url = null;
#[ORM\Column]
private ?bool $active = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $title = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $sub_title = null;
// , columnDefinition:"ENUM('hotel','slider')" // Error : Unknown database type enum requested, Doctrine\DBAL\Platforms\MySQLPlatform may not support it.
#[ORM\Column(length: 255, nullable: true)]
private ?string $type;
#[ORM\ManyToOne(inversedBy: 'images')]
private ?Product $product = null;
#[ORM\OneToOne(mappedBy: 'logo', cascade: ['persist', 'remove'])]
private ?Airline $airline = null;
public function __construct()
{
$this->active = true;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDirectoryPath(): ?string
{
return $this->directoryPath;
}
public function setDirectoryPath(string $directoryPath): self
{
$this->directoryPath = $directoryPath;
return $this;
}
public function getPath(): ?string{
return $this->getDirectoryPath().'/'.$this->name;
}
public function getExtension(): ?string
{
return $this->extension;
}
public function setExtension(string $extension): self
{
$this->extension = $extension;
return $this;
}
public function getAlt(): ?string
{
return $this->alt;
}
public function setAlt(?string $alt): self
{
$this->alt = $alt;
return $this;
}
public function getProvider(): ?Provider
{
return $this->provider;
}
public function setProvider(?Provider $provider): self
{
$this->provider = $provider;
return $this;
}
/**
* @return mixed
*/
public function getDisplayOrder()
{
return $this->displayOrder;
}
/**
* @param mixed $displayOrder
*/
public function setDisplayOrder(mixed $displayOrder): void
{
$this->displayOrder = $displayOrder;
}
public function __toString()
{
return $this->name;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): self
{
$this->title = $title;
return $this;
}
public function getSubTitle(): ?string
{
return $this->sub_title;
}
public function setSubTitle(?string $sub_title): self
{
$this->sub_title = $sub_title;
return $this;
}
/**
* @param string|null $type
*/
public function setType(?string $type): void
{
$this->type = $type;
}
/**
* @return string|null
*/
public function getType(): ?string
{
return $this->type;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): static
{
$this->product = $product;
return $this;
}
public function getAirline(): ?Airline
{
return $this->airline;
}
public function setAirline(?Airline $airline): static
{
// unset the owning side of the relation if necessary
if ($airline === null && $this->airline !== null) {
$this->airline->setLogo(null);
}
// set the owning side of the relation if necessary
if ($airline !== null && $airline->getLogo() !== $this) {
$airline->setLogo($this);
}
$this->airline = $airline;
return $this;
}
}