<?php
namespace App\Entity\Gos\Uniqskills;
use App\Entity\Gos\Language;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\Gos\Uniqskills\VoucherRepository")
* @Vich\Uploadable()
* @ORM\HasLifecycleCallbacks()
*/
class Voucher
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $pageOrientationLandscape;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Gos\Language", inversedBy="vouchers")
* @ORM\JoinTable(name="voucher_language_defaults")
*/
private $isDefaultForLanguage;
/**
* @ORM\OneToOne(targetEntity="App\Entity\Gos\Uniqskills\Course", inversedBy="voucher")
* @ORM\JoinColumn(referencedColumnName="id", onDelete="cascade")
*/
private $course;
/**
* @Assert\File(
* maxSize="5M",
* mimeTypes={"application/pdf", "application/x-pdf"}
* )
*
* @Vich\UploadableField(mapping="product_image", fileNameProperty="pdfName")
*/
private $file;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $pdfName;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Gos\Uniqskills\VoucherElement", mappedBy="voucher")
*/
private $voucherElements;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
public function __construct()
{
$this->isDefaultForLanguage = new ArrayCollection();
$this->voucherElements = new ArrayCollection();
}
/** @ORM\PrePersist() */
public function prePersist()
{
$this->createdAt = new \DateTime();
}
/** @ORM\PreUpdate() */
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
public function __toString()
{
return (string) $this->name;
}
public function setFile(File $voucherTemplate = null): self
{
$this->file = $voucherTemplate;
if ($voucherTemplate)
{
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}
public function getFile(): ?File
{
return $this->file;
}
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 getPageOrientationLandscape(): ?bool
{
return $this->pageOrientationLandscape;
}
public function setPageOrientationLandscape(?bool $pageOrientationLandscape): self
{
$this->pageOrientationLandscape = $pageOrientationLandscape;
return $this;
}
public function getPdfName(): ?string
{
return $this->pdfName;
}
public function setPdfName(?string $pdfName): self
{
$this->pdfName = $pdfName;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @return Collection|Language[]
*/
public function getIsDefaultForLanguage(): Collection
{
return $this->isDefaultForLanguage;
}
public function addIsDefaultForLanguage(Language $isDefaultForLanguage): self
{
if (!$this->isDefaultForLanguage->contains($isDefaultForLanguage)) {
$this->isDefaultForLanguage[] = $isDefaultForLanguage;
}
return $this;
}
public function removeIsDefaultForLanguage(Language $isDefaultForLanguage): self
{
if ($this->isDefaultForLanguage->contains($isDefaultForLanguage)) {
$this->isDefaultForLanguage->removeElement($isDefaultForLanguage);
}
return $this;
}
public function getCourse(): ?Course
{
return $this->course;
}
public function setCourse(?Course $course): self
{
$this->course = $course;
return $this;
}
/**
* @return Collection|VoucherElement[]
*/
public function getVoucherElements(): Collection
{
return $this->voucherElements;
}
public function addVoucherElement(VoucherElement $voucherElement): self
{
if (!$this->voucherElements->contains($voucherElement)) {
$this->voucherElements[] = $voucherElement;
$voucherElement->setVoucher($this);
}
return $this;
}
public function removeVoucherElement(VoucherElement $voucherElement): self
{
if ($this->voucherElements->contains($voucherElement)) {
$this->voucherElements->removeElement($voucherElement);
// set the owning side to null (unless already changed)
if ($voucherElement->getVoucher() === $this) {
$voucherElement->setVoucher(null);
}
}
return $this;
}
}