src/Entity/PaymentMode.php line 11

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PaymentModeRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassPaymentModeRepository::class)]
  8. class PaymentMode
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $code null;
  16.     #[ORM\Column(length255)]
  17.     private ?string $libelle null;
  18.     /**
  19.      * NOTE: `mappedBy` must match the property name on Payment (e.g. `$paymentmode`).
  20.      */
  21.     #[ORM\OneToMany(mappedBy'paymentmode'targetEntityPayment::class, cascade: ['persist'], orphanRemovalfalse)]
  22.     private Collection $payments;
  23.     #[ORM\Column(nullabletrue)]
  24.     private ?bool $status null;
  25.     /**
  26.      * NOTE: `mappedBy` must match the property name on Pay (e.g. `$paymentmode`).
  27.      */
  28.     #[ORM\OneToMany(mappedBy'paymentmode'targetEntityPay::class, cascade: ['persist'], orphanRemovalfalse)]
  29.     private Collection $pays;
  30.     public function __construct()
  31.     {
  32.         $this->payments = new ArrayCollection();
  33.         $this->pays = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getCode(): ?string
  40.     {
  41.         return $this->code;
  42.     }
  43.     public function setCode(?string $code): self
  44.     {
  45.         $this->code $code;
  46.         return $this;
  47.     }
  48.     public function getLibelle(): ?string
  49.     {
  50.         return $this->libelle;
  51.     }
  52.     public function setLibelle(?string $libelle): self
  53.     {
  54.         $this->libelle $libelle;
  55.         return $this;
  56.     }
  57.     /** @return Collection<int, Payment> */
  58.     public function getPayments(): Collection
  59.     {
  60.         return $this->payments;
  61.     }
  62.     public function addPayment(Payment $payment): self
  63.     {
  64.         if (!$this->payments->contains($payment)) {
  65.             $this->payments->add($payment);
  66.             // Keep owning side in sync
  67.             if (method_exists($payment'setPaymentmode')) {
  68.                 $payment->setPaymentmode($this);
  69.             }
  70.         }
  71.         return $this;
  72.     }
  73.     public function removePayment(Payment $payment): self
  74.     {
  75.         if ($this->payments->removeElement($payment)) {
  76.             if (method_exists($payment'getPaymentmode') && $payment->getPaymentmode() === $this) {
  77.                 $payment->setPaymentmode(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82.     public function getStatus(): ?bool
  83.     {
  84.         return $this->status;
  85.     }
  86.     // Symfony will also look for "isStatus" on booleans; keep both for compatibility.
  87.     public function isStatus(): ?bool
  88.     {
  89.         return $this->status;
  90.     }
  91.     public function setStatus(?bool $status): self
  92.     {
  93.         $this->status $status;
  94.         return $this;
  95.     }
  96.     /** @return Collection<int, Pay> */
  97.     public function getPays(): Collection
  98.     {
  99.         return $this->pays;
  100.     }
  101.     public function addPay(Pay $pay): self
  102.     {
  103.         if (!$this->pays->contains($pay)) {
  104.             $this->pays->add($pay);
  105.             if (method_exists($pay'setPaymentmode')) {
  106.                 $pay->setPaymentmode($this);
  107.             }
  108.         }
  109.         return $this;
  110.     }
  111.     public function removePay(Pay $pay): self
  112.     {
  113.         if ($this->pays->removeElement($pay)) {
  114.             if (method_exists($pay'getPaymentmode') && $pay->getPaymentmode() === $this) {
  115.                 $pay->setPaymentmode(null);
  116.             }
  117.         }
  118.         return $this;
  119.     }
  120.     public function __toString(): string
  121.     {
  122.         // Avoid returning null to prevent "must be of type string, null returned"
  123.         return $this->libelle
  124.             ?? $this->code
  125.             ?? sprintf('Mode #%s'$this->id ?? 'N/A');
  126.     }
  127. }