src/Entity/PaymentMethod.php line 22

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use App\Repository\PaymentMethodRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClassPaymentMethodRepository::class)]
  11. #[ApiResource(
  12.     operations: [
  13.         new GetCollection()
  14.     ],
  15.     normalizationContext: [
  16.         'groups' => ['read:payment_method:collection']
  17.     ]
  18. )]
  19. class PaymentMethod
  20. {
  21.     #[ORM\Id]
  22.     #[ORM\GeneratedValue]
  23.     #[ORM\Column]
  24.     #[Groups(['read:course:item''read:payment:collection''read:payment_method:collection'])]
  25.     private ?int $id null;
  26.     #[ORM\Column(length255)]
  27.     #[Groups(['read:course:item''read:payment:collection''read:payment_method:collection'])]
  28.     private ?string $label null;
  29.     #[ORM\Column(length50)]
  30.     #[Groups(['read:course:item''read:payment:collection''read:payment_method:collection'])]
  31.     private ?string $code null;
  32.     #[ORM\Column(length255)]
  33.     #[Groups(['read:course:item''read:payment:collection''read:payment_method:collection'])]
  34.     private ?string $slug null;
  35.     #[ORM\OneToMany(mappedBy'paymentMethod'targetEntityPayment::class)]
  36.     private Collection $payments;
  37.     #[ORM\ManyToMany(targetEntityCours::class, mappedBy'paymentMethods')]
  38.     private Collection $cours;
  39.     #[ORM\ManyToMany(targetEntityAbonnement::class, mappedBy'paymentMethods')]
  40.     private Collection $abonnements;
  41.     #[ORM\OneToMany(mappedBy'paymentMethod'targetEntityRetrait::class, orphanRemovaltrue)]
  42.     private Collection $retraits;
  43.     public function __construct()
  44.     {
  45.         $this->payments = new ArrayCollection();
  46.         $this->cours = new ArrayCollection();
  47.         $this->abonnements = new ArrayCollection();
  48.         $this->retraits = new ArrayCollection();
  49.     }
  50.     public function getId(): ?int
  51.     {
  52.         return $this->id;
  53.     }
  54.     public function getLabel(): ?string
  55.     {
  56.         return $this->label;
  57.     }
  58.     public function setLabel(string $label): self
  59.     {
  60.         $this->label $label;
  61.         return $this;
  62.     }
  63.     public function getCode(): ?string
  64.     {
  65.         return $this->code;
  66.     }
  67.     public function setCode(string $code): self
  68.     {
  69.         $this->code $code;
  70.         return $this;
  71.     }
  72.     public function getSlug(): ?string
  73.     {
  74.         return $this->slug;
  75.     }
  76.     public function setSlug(string $slug): self
  77.     {
  78.         $this->slug $slug;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection<int, Payment>
  83.      */
  84.     public function getPayments(): Collection
  85.     {
  86.         return $this->payments;
  87.     }
  88.     public function addPayment(Payment $payment): self
  89.     {
  90.         if (!$this->payments->contains($payment)) {
  91.             $this->payments->add($payment);
  92.             $payment->setPaymentMethod($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removePayment(Payment $payment): self
  97.     {
  98.         if ($this->payments->removeElement($payment)) {
  99.             // set the owning side to null (unless already changed)
  100.             if ($payment->getPaymentMethod() === $this) {
  101.                 $payment->setPaymentMethod(null);
  102.             }
  103.         }
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection<int, Cours>
  108.      */
  109.     public function getCours(): Collection
  110.     {
  111.         return $this->cours;
  112.     }
  113.     public function addCour(Cours $cour): self
  114.     {
  115.         if (!$this->cours->contains($cour)) {
  116.             $this->cours->add($cour);
  117.             $cour->addPaymentMethod($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removeCour(Cours $cour): self
  122.     {
  123.         if ($this->cours->removeElement($cour)) {
  124.             $cour->removePaymentMethod($this);
  125.         }
  126.         return $this;
  127.     }
  128.     /**
  129.      * @return Collection<int, Abonnement>
  130.      */
  131.     public function getAbonnements(): Collection
  132.     {
  133.         return $this->abonnements;
  134.     }
  135.     public function addAbonnement(Abonnement $abonnement): self
  136.     {
  137.         if (!$this->abonnements->contains($abonnement)) {
  138.             $this->abonnements->add($abonnement);
  139.             $abonnement->addPaymentMethod($this);
  140.         }
  141.         return $this;
  142.     }
  143.     public function removeAbonnement(Abonnement $abonnement): self
  144.     {
  145.         if ($this->abonnements->removeElement($abonnement)) {
  146.             $abonnement->removePaymentMethod($this);
  147.         }
  148.         return $this;
  149.     }
  150.     /**
  151.      * @return Collection<int, Retrait>
  152.      */
  153.     public function getRetraits(): Collection
  154.     {
  155.         return $this->retraits;
  156.     }
  157.     public function addRetrait(Retrait $retrait): static
  158.     {
  159.         if (!$this->retraits->contains($retrait)) {
  160.             $this->retraits->add($retrait);
  161.             $retrait->setPaymentMethod($this);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeRetrait(Retrait $retrait): static
  166.     {
  167.         if ($this->retraits->removeElement($retrait)) {
  168.             // set the owning side to null (unless already changed)
  169.             if ($retrait->getPaymentMethod() === $this) {
  170.                 $retrait->setPaymentMethod(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175. }