<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\HearingMakerRepository")
* @Vich\Uploadable
*/
class HearingMaker
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255)
*/
private $logoPath;
/**
* @assert\File( mimeTypes = {"image/jpeg", "image/png", "image/gif", "image/jpg"})
* @Vich\UploadableField(mapping="brand_logo", fileNameProperty="logoPath")
* @var File
*/
private $logoFile;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phoneNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $address;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $wording;
/**
* @ORM\OneToMany(targetEntity=HearingAid::class, mappedBy="hearingMaker")
*/
private $hearingAids;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $mediaoptinCampaignId;
public function __construct()
{
$this->hearingAids = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* Représente l'entité par défault
* @return string
*/
public function __toString(){
return 'HearingBrand '.$this->getName().' ['.$this->getId().']';
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function isUpdated():bool
{
if($this->updatedAt !== NULL) {
if(date_diff($this->updatedAt, new \DateTime('now'))->days < 31 ) {
return true;
}
}
return false;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getWording(): ?string
{
return $this->wording;
}
public function setWording(?string $wording): self
{
$this->wording = $wording;
return $this;
}
public function getLogoPath(): ?string
{
return $this->logoPath;
}
public function setLogoPath(string $logoPath=null): self
{
$this->logoPath = $logoPath;
return $this;
}
/**
* @return bool
*/
public function hasLogo(){
return !is_null($this->logoPath);
}
public function setLogoFile(File $image = null)
{
$this->logoFile = $image;
//update timestamp
if ($image) {
$this->updatedAt = new DateTime('now');
}
}
public function getLogoFile()
{
return $this->logoFile;
}
/**
* @return Collection|StorePage[]
*/
public function getStorePages(): Collection
{
return $this->storePages;
}
public function addStorePage(StorePage $storePage): self
{
if (!$this->storePages->contains($storePage)) {
$this->storePages[] = $storePage;
$storePage->addHearingMaker($this);
}
return $this;
}
public function removeStorePage(StorePage $storePage): self
{
if ($this->storePages->contains($storePage)) {
$this->storePages->removeElement($storePage);
$storePage->removeHearingMaker($this);
}
return $this;
}
/**
* @return Collection|HearingAid[]
*/
public function getHearingAids(): Collection
{
return $this->hearingAids;
}
public function addHearingAid(HearingAid $hearingAid): self
{
if (!$this->hearingAids->contains($hearingAid)) {
$this->hearingAids[] = $hearingAid;
$hearingAid->setHearingMaker($this);
}
return $this;
}
public function removeHearingAid(HearingAid $hearingAid): self
{
if ($this->hearingAids->contains($hearingAid)) {
$this->hearingAids->removeElement($hearingAid);
// set the owning side to null (unless already changed)
if ($hearingAid->getHearingMaker() === $this) {
$hearingAid->setHearingMaker(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getMediaoptinCampaignId()
{
return $this->mediaoptinCampaignId;
}
/**
* @param mixed $mediaoptinCampaignId
*/
public function setMediaoptinCampaignId($mediaoptinCampaignId): void
{
$this->mediaoptinCampaignId = $mediaoptinCampaignId;
}
}