<?php
namespace App\Entity;
use App\Repository\DocumentModelRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: DocumentModelRepository::class)]
#[ORM\HasLifecycleCallbacks]
class DocumentModel
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 100)]
private $name;
#[ORM\Column(type: 'boolean')]
private $isForMinor = true;
#[ORM\Column(type: 'boolean')]
private $isForAdult = true;
#[ORM\Column(type: 'boolean')]
private $isPhysical = false;
#[ORM\Column(type: 'boolean')]
private $isCroppable = false;
#[ORM\Column(type: 'json', nullable: true)]
private $allowedMimeTypes = ['image/*', 'application/pdf'];
#[ORM\OneToOne(targetEntity: File::class, cascade: ['persist', 'remove'])]
private $file;
#[ORM\ManyToOne(targetEntity: Season::class, inversedBy: 'documentModels')]
#[ORM\JoinColumn(nullable: false)]
private $season;
#[ORM\ManyToMany(targetEntity: self::class, inversedBy: 'children')]
#[ORM\JoinTable(name: 'document_model_link')]
#[ORM\JoinColumn('parent_id', 'id')]
#[ORM\InverseJoinColumn('child_id', 'id')]
private $parents;
#[ORM\ManyToMany(targetEntity: self::class, mappedBy: 'parents')]
private $children;
#[ORM\OneToMany(mappedBy: 'model', targetEntity: Document::class)]
private $documents;
#[ORM\ManyToOne(targetEntity: DiscountModel::class, inversedBy: 'documentModels')]
private $discountModel;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
private $linkedDocuments;
#[ORM\Column(length: 255, nullable: true)]
private ?string $slug = null;
#[ORM\Column(nullable: true)]
private ?bool $adminOnly = null;
public function __construct()
{
$this->parents = new ArrayCollection();
$this->children = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->linkedDocuments = new ArrayCollection();
}
public function __toString(): string
{
return $this->getName();
}
public function __clone()
{
$this->id = null;
$this->parents = new ArrayCollection();
$this->children = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->linkedDocuments = new ArrayCollection();
}
#[ORM\PostLoad]
public function postLoad()
{
$this->linkedDocuments = new ArrayCollection();
}
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 getIsForMinor(): ?bool
{
return $this->isForMinor;
}
public function setIsForMinor(bool $isForMinor): self
{
$this->isForMinor = $isForMinor;
return $this;
}
public function getIsForAdult(): ?bool
{
return $this->isForAdult;
}
public function setIsForAdult(bool $isForAdult): self
{
$this->isForAdult = $isForAdult;
return $this;
}
public function getIsPhysical(): ?bool
{
return $this->isPhysical;
}
public function setIsPhysical(bool $isPhysical): self
{
$this->isPhysical = $isPhysical;
return $this;
}
public function getIsCroppable(): ?bool
{
return $this->isCroppable;
}
public function setIsCroppable(bool $isCroppable): self
{
$this->isCroppable = $isCroppable;
return $this;
}
public function getAllowedMimeTypes(): ?array
{
return $this->allowedMimeTypes;
}
public function setAllowedMimeTypes(?array $allowedMimeTypes): self
{
$this->allowedMimeTypes = $allowedMimeTypes;
return $this;
}
public function getFile(): ?File
{
return $this->file;
}
public function setFile(?File $file): self
{
$this->file = $file;
return $this;
}
public function getSeason(): ?Season
{
return $this->season;
}
public function setSeason(?Season $season): self
{
$this->season = $season;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getParents(): Collection
{
return $this->parents;
}
public function addParent(self $parent): self
{
if (!$this->parents->contains($parent)) {
$this->parents[] = $parent;
}
return $this;
}
public function removeParent(self $parent): self
{
$this->parents->removeElement($parent);
return $this;
}
/**
* @return Collection<int, self>
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(self $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->addParent($this);
}
return $this;
}
public function removeChild(self $child): self
{
if ($this->children->removeElement($child)) {
$child->removeParent($this);
}
return $this;
}
/**
* @return Collection<int, Document>
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setModel($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->removeElement($document)) {
// set the owning side to null (unless already changed)
if ($document->getModel() === $this) {
$document->setModel(null);
}
}
return $this;
}
public function getDiscountModel(): ?DiscountModel
{
return $this->discountModel;
}
public function setDiscountModel(?DiscountModel $discountModel): self
{
$this->discountModel = $discountModel;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, Document>
*/
public function getLinkedDocuments(): Collection
{
return $this->linkedDocuments;
}
public function addLinkedDocument(Document $document): self
{
if (!$this->linkedDocuments->contains($document)) {
$this->linkedDocuments[] = $document;
}
return $this;
}
public function removeLinkedDocument(Document $document): self
{
$this->linkedDocuments->removeElement($document);
return $this;
}
public function emptyLinkedDocuments(): self
{
$this->linkedDocuments = new ArrayCollection();
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
public function isAdminOnly(): ?bool
{
return $this->adminOnly;
}
public function setAdminOnly(?bool $adminOnly): self
{
$this->adminOnly = $adminOnly;
return $this;
}
}