<?php
namespace App\Entity\Garages;
use App\Annotation\SiteAware;
use App\Entity\AbstractBase;
use App\Entity\Interfaces\DocumentInterface;
use App\Entity\Interfaces\ImageInterface;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\MiniAbstractBase;
use App\Entity\Traits\HasDocumentTrait;
use App\Entity\Traits\HasImageTrait;
use App\Entity\Traits\NameTrait;
use App\Entity\Traits\PublishedTrait;
use App\Entity\Traits\SiteTrait;
use App\Enum\GarageOffer2TypeEnum;
use App\Repository\Garages\GarageOffer2Repository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Table(name="vulco_garage_offer_2", indexes={@ORM\Index(name="garage_offer_2_site_idx", columns={"site"})})
* @ORM\Entity(repositoryClass=GarageOffer2Repository::class)
* @Gedmo\SoftDeleteable(fieldName="removedAt", timeAware=false)
* @SiteAware(siteFieldName="site")
* @Vich\Uploadable
*/
class GarageOffer2 extends AbstractBase implements SiteInterface, DocumentInterface, ImageInterface
{
use HasDocumentTrait;
use HasImageTrait;
use NameTrait;
use PublishedTrait;
use SiteTrait;
/**
* @Vich\UploadableField(mapping="garage_offer_2_document", fileNameProperty="documentName")
*/
private ?File $document = null;
/**
* @Vich\UploadableField(mapping="garage_offer_2_image", fileNameProperty="documentName")
*/
private ?File $image = null;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $name;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private int $offerType;
/**
* @ORM\Column(type="date", nullable=true)
*/
private ?\DateTimeInterface $startDate = null;
/**
* @ORM\Column(type="date", nullable=true)
*/
private ?\DateTimeInterface $endDate = null;
/**
* @ORM\Column(type="text", length=10000, nullable=true)
*/
private ?string $emailText = null;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Garages\Garage", cascade={"persist"})
* @ORM\JoinTable(name="vulco_garage_offer_2_garage",
* joinColumns={@ORM\JoinColumn(name="garage_offer_2_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="garage_id", referencedColumnName="id")}
* )
*/
private ?Collection $garages;
/**
* TODO ORM\OneToMany(targetEntity="App\Entity\Garages\BudgetRequest", mappedBy="garageOffer2", orphanRemoval=false)
* TODO ORM\OrderBy({"createdAt": "DESC"}).
*/
private ?Collection $budgetRequests;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Garages\GarageAppointment", mappedBy="garageOffer2", orphanRemoval=false)
* @ORM\OrderBy({"createdAt": "DESC"})
*/
private ?Collection $garageAppointments;
public function __construct()
{
$this->garages = new ArrayCollection();
$this->budgetRequests = new ArrayCollection();
$this->garageAppointments = new ArrayCollection();
}
public function getOfferType(): int
{
return $this->offerType;
}
public function getOfferTypeString(): string
{
$result = MiniAbstractBase::DEFAULT_EMPTY_STRING;
if (array_key_exists($this->getOfferType(), GarageOffer2TypeEnum::getTranslations())) {
$result = GarageOffer2TypeEnum::getTranslations()[$this->getOfferType()];
}
return $result;
}
public function setOfferType(int $offerType): self
{
$this->offerType = $offerType;
return $this;
}
public function getStartDate(): ?\DateTimeInterface
{
return $this->startDate;
}
public function setStartDate(?\DateTimeInterface $startDate): self
{
$this->startDate = $startDate;
return $this;
}
public function getEndDate(): ?\DateTimeInterface
{
return $this->endDate;
}
public function setEndDate(?\DateTimeInterface $endDate): self
{
$this->endDate = $endDate;
return $this;
}
public function getEmailText(): ?string
{
return $this->emailText;
}
public function setEmailText(?string $emailText): self
{
$this->emailText = $emailText;
return $this;
}
public function getGarages(): ?Collection
{
return $this->garages;
}
public function addGarage(Garage $garage): self
{
if (!$this->garages->contains($garage)) {
$this->garages->add($garage);
}
return $this;
}
public function setGarages(?Collection $garages): self
{
$this->garages = $garages;
return $this;
}
public function getBudgetRequests(): ?Collection
{
return $this->budgetRequests;
}
public function setBudgetRequests(?Collection $budgetRequests): self
{
$this->budgetRequests = $budgetRequests;
return $this;
}
public function getGarageAppointments(): ?Collection
{
return $this->garageAppointments;
}
public function setGarageAppointments(?Collection $garageAppointments): self
{
$this->garageAppointments = $garageAppointments;
return $this;
}
public function __toString(): string
{
return $this->id ? $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
}
}