src/Entity/HearingMaker.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use DateTime;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\HearingMakerRepository")
  12.  * @Vich\Uploadable
  13.  */
  14. class HearingMaker
  15. {
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      */
  29.     private $slug;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $logoPath;
  34.     /**
  35.      * @assert\File( mimeTypes = {"image/jpeg", "image/png", "image/gif", "image/jpg"})
  36.      * @Vich\UploadableField(mapping="brand_logo", fileNameProperty="logoPath")
  37.      * @var File
  38.      */
  39.     private $logoFile;
  40.     /**
  41.      * @ORM\Column(type="datetime", nullable=true)
  42.      */
  43.     private $updatedAt;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $phoneNumber;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $address;
  52.     /**
  53.      * @ORM\Column(type="text", nullable=true)
  54.      */
  55.     private $wording;
  56.     /**
  57.      * @ORM\OneToMany(targetEntity=HearingAid::class, mappedBy="hearingMaker")
  58.      */
  59.     private $hearingAids;
  60.     /**
  61.      * @ORM\Column(type="integer", nullable=true)
  62.      */
  63.     private $mediaoptinCampaignId;
  64.     public function __construct()
  65.     {
  66.         $this->hearingAids = new ArrayCollection();
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     /**
  73.      * Représente l'entité par défault
  74.      * @return string
  75.      */
  76.     public function __toString(){
  77.         return 'HearingBrand '.$this->getName().' ['.$this->getId().']';
  78.     }
  79.     public function getName(): ?string
  80.     {
  81.         return $this->name;
  82.     }
  83.     public function setName(string $name): self
  84.     {
  85.         $this->name $name;
  86.         return $this;
  87.     }
  88.     public function getSlug(): ?string
  89.     {
  90.         return $this->slug;
  91.     }
  92.     public function setSlug(string $slug): self
  93.     {
  94.         $this->slug $slug;
  95.         return $this;
  96.     }
  97.     public function getUpdatedAt(): ?\DateTimeInterface
  98.     {
  99.         return $this->updatedAt;
  100.     }
  101.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  102.     {
  103.         $this->updatedAt $updatedAt;
  104.         return $this;
  105.     }
  106.     public function isUpdated():bool
  107.     {
  108.         if($this->updatedAt !== NULL) {
  109.             if(date_diff($this->updatedAt, new \DateTime('now'))->days 31 ) {
  110.                 return true;
  111.             }
  112.         }
  113.         return false;
  114.     }
  115.     public function getPhoneNumber(): ?string
  116.     {
  117.         return $this->phoneNumber;
  118.     }
  119.     public function setPhoneNumber(?string $phoneNumber): self
  120.     {
  121.         $this->phoneNumber $phoneNumber;
  122.         return $this;
  123.     }
  124.     public function getAddress(): ?string
  125.     {
  126.         return $this->address;
  127.     }
  128.     public function setAddress(?string $address): self
  129.     {
  130.         $this->address $address;
  131.         return $this;
  132.     }
  133.     public function getWording(): ?string
  134.     {
  135.         return $this->wording;
  136.     }
  137.     public function setWording(?string $wording): self
  138.     {
  139.         $this->wording $wording;
  140.         return $this;
  141.     }
  142.     public function getLogoPath(): ?string
  143.     {
  144.         return $this->logoPath;
  145.     }
  146.     public function setLogoPath(string $logoPath=null): self
  147.     {
  148.         $this->logoPath $logoPath;
  149.         return $this;
  150.     }
  151.     /**
  152.      * @return bool
  153.      */
  154.     public function hasLogo(){
  155.         return !is_null($this->logoPath);
  156.     }
  157.     public function setLogoFile(File $image null)
  158.     {
  159.         $this->logoFile $image;
  160.         //update timestamp
  161.         if ($image) {
  162.             $this->updatedAt = new DateTime('now');
  163.         }
  164.     }
  165.     public function getLogoFile()
  166.     {
  167.         return $this->logoFile;
  168.     }
  169.     /**
  170.      * @return Collection|StorePage[]
  171.      */
  172.     public function getStorePages(): Collection
  173.     {
  174.         return $this->storePages;
  175.     }
  176.     public function addStorePage(StorePage $storePage): self
  177.     {
  178.         if (!$this->storePages->contains($storePage)) {
  179.             $this->storePages[] = $storePage;
  180.             $storePage->addHearingMaker($this);
  181.         }
  182.         return $this;
  183.     }
  184.     public function removeStorePage(StorePage $storePage): self
  185.     {
  186.         if ($this->storePages->contains($storePage)) {
  187.             $this->storePages->removeElement($storePage);
  188.             $storePage->removeHearingMaker($this);
  189.         }
  190.         return $this;
  191.     }
  192.     /**
  193.      * @return Collection|HearingAid[]
  194.      */
  195.     public function getHearingAids(): Collection
  196.     {
  197.         return $this->hearingAids;
  198.     }
  199.     public function addHearingAid(HearingAid $hearingAid): self
  200.     {
  201.         if (!$this->hearingAids->contains($hearingAid)) {
  202.             $this->hearingAids[] = $hearingAid;
  203.             $hearingAid->setHearingMaker($this);
  204.         }
  205.         return $this;
  206.     }
  207.     public function removeHearingAid(HearingAid $hearingAid): self
  208.     {
  209.         if ($this->hearingAids->contains($hearingAid)) {
  210.             $this->hearingAids->removeElement($hearingAid);
  211.             // set the owning side to null (unless already changed)
  212.             if ($hearingAid->getHearingMaker() === $this) {
  213.                 $hearingAid->setHearingMaker(null);
  214.             }
  215.         }
  216.         return $this;
  217.     }
  218.     /**
  219.      * @return mixed
  220.      */
  221.     public function getMediaoptinCampaignId()
  222.     {
  223.         return $this->mediaoptinCampaignId;
  224.     }
  225.     /**
  226.      * @param mixed $mediaoptinCampaignId
  227.      */
  228.     public function setMediaoptinCampaignId($mediaoptinCampaignId): void
  229.     {
  230.         $this->mediaoptinCampaignId $mediaoptinCampaignId;
  231.     }
  232. }