src/Modules/RecommendationVoucherForm/Entity/RecommendationVoucherForm.php line 16

  1. <?php
  2. namespace App\Modules\RecommendationVoucherForm\Entity;
  3. use App\Admin\Modules\Voucher\Entity\VoucherPackageVoucher;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. /**
  10.  * @ORM\Table(name="recommendation_voucher_form", uniqueConstraints={@ORM\UniqueConstraint(columns={"id_voucher_package_voucher"})})
  11.  * @ORM\Entity
  12.  */
  13. class RecommendationVoucherForm
  14. {
  15.     /**
  16.      * @ORM\Column(type="bigint", options={"unsigned"=true}))
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue(strategy="AUTO")
  19.      */
  20.     private $id;
  21.     
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity="App\Admin\Modules\Voucher\Entity\VoucherPackageVoucher", inversedBy="recommendationVoucherForm")
  24.      * @ORM\JoinColumns({
  25.      *   @ORM\JoinColumn(name="id_voucher_package_voucher", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  26.      * })
  27.      */
  28.     private $voucher;    
  29.     
  30.     /**
  31.      * @ORM\Column(name="added_at", type="datetime", nullable=false)
  32.      * @Gedmo\Timestampable(on="create")
  33.      */
  34.     private $addedAt;
  35.     
  36.     /**
  37.      * @ORM\OneToMany(targetEntity="App\Modules\RecommendationVoucherForm\Entity\RecommendationVoucherFormField", mappedBy="form", cascade={"persist"}, orphanRemoval=true)
  38.      * @ORM\OrderBy({"id"="ASC"})
  39.      */
  40.     private $formFields;
  41.     
  42.     /**
  43.      * @ORM\ManyToMany(targetEntity="App\Admin\Modules\Voucher\Entity\VoucherPackageVoucher")
  44.      * @ORM\JoinTable(name="recommendation_voucher_form_voucher",
  45.      *      joinColumns={@ORM\JoinColumn(name="recommendation_voucher_form", referencedColumnName="id", onDelete="CASCADE")},
  46.      *      inverseJoinColumns={@ORM\JoinColumn(name="id_voucher_package_voucher", referencedColumnName="id", onDelete="CASCADE")}
  47.      *    )
  48.      * @ORM\OrderBy({"id"="ASC"})
  49.      **/
  50.     private $vouchers;    
  51.     public function __construct()
  52.     {
  53.         $this->formFields = new ArrayCollection();
  54.         $this->vouchers = new ArrayCollection();
  55.     }
  56.     public function getId(): ?string
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getAddedAt(): ?\DateTimeInterface
  61.     {
  62.         return $this->addedAt;
  63.     }
  64.     public function setAddedAt(\DateTimeInterface $addedAt): self
  65.     {
  66.         $this->addedAt $addedAt;
  67.         return $this;
  68.     }
  69.     public function getVoucher(): ?VoucherPackageVoucher
  70.     {
  71.         return $this->voucher;
  72.     }
  73.     public function setVoucher(?VoucherPackageVoucher $voucher): self
  74.     {
  75.         $this->voucher $voucher;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection<int, RecommendationVoucherFormField>
  80.      */
  81.     public function getFormFields(): Collection
  82.     {
  83.         return $this->formFields;
  84.     }
  85.     public function addFormField(RecommendationVoucherFormField $formField): self
  86.     {
  87.         if (!$this->formFields->contains($formField)) {
  88.             $this->formFields->add($formField);
  89.             $formField->setForm($this);
  90.         }
  91.         return $this;
  92.     }
  93.     public function removeFormField(RecommendationVoucherFormField $formField): self
  94.     {
  95.         if ($this->formFields->removeElement($formField)) {
  96.             // set the owning side to null (unless already changed)
  97.             if ($formField->getForm() === $this) {
  98.                 $formField->setForm(null);
  99.             }
  100.         }
  101.         return $this;
  102.     }
  103.     /**
  104.      * @return Collection<int, VoucherPackageVoucher>
  105.      */
  106.     public function getVouchers(): Collection
  107.     {
  108.         return $this->vouchers;
  109.     }
  110.     public function addVoucher(VoucherPackageVoucher $voucher): self
  111.     {
  112.         if (!$this->vouchers->contains($voucher)) {
  113.             $this->vouchers->add($voucher);
  114.         }
  115.         return $this;
  116.     }
  117.     public function removeVoucher(VoucherPackageVoucher $voucher): self
  118.     {
  119.         $this->vouchers->removeElement($voucher);
  120.         return $this;
  121.     }
  122. }