src/Entity/ProspectOnStoreFeedback.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Enum\ProspectOnStoreFeedbackStateEnum;
  4. use App\Entity\Enum\ProspectOnStoreStatusEnum;
  5. use App\Repository\ProspectOnStoreFeedbackRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. /**
  11.  * @ORM\Entity(repositoryClass=ProspectOnStoreFeedbackRepository::class)
  12.  */
  13. class ProspectOnStoreFeedback
  14. {
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\OneToOne(targetEntity=ProspectOnStore::class, mappedBy="feedback")
  23.      */
  24.     private $prospectOnStore;
  25.     /**
  26.      * @ORM\Column(type="datetime")
  27.      * @Gedmo\Timestampable(on="create")
  28.      */
  29.     private $created;
  30.     /**
  31.      * @ORM\Column(type="datetime", nullable=true)
  32.      */
  33.     private $openedDate;
  34.     /**
  35.      * @ORM\Column(type="string", length=50, unique=true)
  36.      */
  37.     private $token;
  38.     /**
  39.      * @ORM\Column(type="string", length=5, nullable=true)
  40.      */
  41.     private $answer;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=ProspectOnStore::class, mappedBy="prospectOnStoreFeedbackOrigin")
  44.      */
  45.     private $prospectOnStoreGenerated;
  46.     /**
  47.      * @ORM\Column(type="string", length=5, nullable=true)
  48.      */
  49.     private $state;
  50.     public function __construct()
  51.     {
  52.         $this->prospectOnStoreGenerated = new ArrayCollection();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getProspectOnStore(): ?ProspectOnStore
  59.     {
  60.         return $this->prospectOnStore;
  61.     }
  62.     public function setProspectOnStore(?ProspectOnStore $prospectOnStore): self
  63.     {
  64.         $this->prospectOnStore $prospectOnStore;
  65.         $prospectOnStore->setFeedback($this);
  66.         return $this;
  67.     }
  68.     public function getCreated(): ?\DateTimeInterface
  69.     {
  70.         return $this->created;
  71.     }
  72.     public function setCreated(?\DateTimeInterface $created): self
  73.     {
  74.         $this->created $created;
  75.         return $this;
  76.     }
  77.     public function getOpenedDate(): ?\DateTimeInterface
  78.     {
  79.         return $this->openedDate;
  80.     }
  81.     public function setOpenedDate(?\DateTimeInterface $openedDate): self
  82.     {
  83.         $this->openedDate $openedDate;
  84.         $this->setState(ProspectOnStoreFeedbackStateEnum::OPENED);
  85.         return $this;
  86.     }
  87.     public function getToken(): ?string
  88.     {
  89.         return $this->token;
  90.     }
  91.     public function setToken(string $token): self
  92.     {
  93.         $this->token $token;
  94.         return $this;
  95.     }
  96.     public function getAnswer(): ?string
  97.     {
  98.         return $this->answer;
  99.     }
  100.     public function setAnswer(?string $answer): self
  101.     {
  102.         $this->answer $answer;
  103.         $this->setState(ProspectOnStoreFeedbackStateEnum::ANSWER);
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection|ProspectOnStore[]
  108.      */
  109.     public function getProspectOnStoreGenerated(): Collection
  110.     {
  111.         return $this->prospectOnStoreGenerated;
  112.     }
  113.     public function addProspectOnStoreGenerated(ProspectOnStore $prospectOnStoreGenerated): self
  114.     {
  115.         if (!$this->prospectOnStoreGenerated->contains($prospectOnStoreGenerated)) {
  116.             $this->prospectOnStoreGenerated[] = $prospectOnStoreGenerated;
  117.             $prospectOnStoreGenerated->setProspectOnStoreFeedbackOrigin($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removeProspectOnStoreGenerated(ProspectOnStore $prospectOnStoreGenerated): self
  122.     {
  123.         if ($this->prospectOnStoreGenerated->contains($prospectOnStoreGenerated)) {
  124.             $this->prospectOnStoreGenerated->removeElement($prospectOnStoreGenerated);
  125.             // set the owning side to null (unless already changed)
  126.             if ($prospectOnStoreGenerated->getProspectOnStoreFeedbackOrigin() === $this) {
  127.                 $prospectOnStoreGenerated->setProspectOnStoreFeedbackOrigin(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     public function getState(): ?string
  133.     {
  134.         return $this->state;
  135.     }
  136.     public function setState(?string $state): self
  137.     {
  138.         $this->state $state;
  139.         return $this;
  140.     }
  141.     /**
  142.      * Return true if this feedback can still be answered
  143.      * @return bool
  144.      */
  145.     public function canBeAnswered(){
  146.         return is_null($this->answer) || $this->answer==|| in_array($this->state, [ProspectOnStoreFeedbackStateEnum::OPENEDProspectOnStoreFeedbackStateEnum::STORE_CHOICE]);
  147.     }
  148. }