<?php
namespace App\Entity\Saloon;
use App\Entity\IMediaFile;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\Mapping\Index;
#[ORM\Table(name: 'saloon_media_files')]
#[Index(name: 'idx_type', columns: ['type'])]
#[Index(name: 'idx_saloon_type', columns: ['saloon_id', 'type'])]
#[ORM\Entity]
#[ORM\InheritanceType('SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'type', type: 'string', length: 12)]
#[ORM\DiscriminatorMap(['photo' => Photo::class, 'thumbnail' => Thumbnail::class, 'video' => Video::class])]
abstract class MediaFile implements IMediaFile
{
#[ORM\Id]
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
protected int $id;
#[ORM\JoinColumn(name: 'saloon_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: Saloon::class)]
protected Saloon $saloon;
#[ORM\Column(name: 'path', type: 'string', length: 128)]
protected string $path;
#[ORM\Column(name: 'preview_path', type: 'string', length: 128, nullable: true)]
protected ?string $previewPath = null;
public function __construct(Saloon $saloon, string $path)
{
$this->saloon = $saloon;
$this->path = $path;
}
public function getId(): int
{
return $this->id;
}
public function getPath(): string
{
return $this->path;
}
public function setPath(string $path): void
{
$this->path = $path;
}
public function getPreviewPath(): ?string
{
return $this->previewPath;
}
public function setPreviewPath(?string $previewPath): void
{
$this->previewPath = $previewPath;
}
}