src/Flexy/ShopBundle/Entity/Payment/PaymentMethod.php line 18

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Payment;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Flexy\ShopBundle\Entity\Accounting\Invoice;
  7. use App\Flexy\ShopBundle\Entity\Order\Order;
  8. use App\Flexy\ShopBundle\Repository\Payment\PaymentMethodRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. #[ApiResource]
  13. #[ApiFilter(SearchFilter::class, properties: ['type' => 'exact'])]
  14. #[ORM\Entity(repositoryClassPaymentMethodRepository::class)]
  15. class PaymentMethod implements \Stringable
  16. {
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column(type'integer')]
  20.     private $id;
  21.     #[ORM\Column(type'string'length255)]
  22.     private ?string $name null;
  23.     #[ORM\Column(type'string'length255nullabletrue)]
  24.     private ?string $image null;
  25.     #[ORM\Column(type'text'nullabletrue)]
  26.     private ?string $description null;
  27.     #[ORM\Column(type'string'length255)]
  28.     private ?string $code null;
  29.     #[ORM\Column(type'boolean'nullabletrue)]
  30.     private ?bool $isEnabled null;
  31.     #[ORM\Column(type'datetime_immutable'nullabletrue)]
  32.     private ?\DateTimeImmutable $createdAt null;
  33.     #[ORM\Column(type'integer'nullabletrue)]
  34.     private ?int $position null;
  35.     #[ORM\OneToMany(targetEntityPayment::class, mappedBy'paymentMethod')]
  36.     private \Doctrine\Common\Collections\Collection|array $payments;
  37.     #[ORM\OneToMany(targetEntityOrder::class, mappedBy'paymentMethod'cascade: ['persist'])]
  38.     #[ORM\JoinColumn(nullabletrueonDelete'CASCADE')]
  39.     private \Doctrine\Common\Collections\Collection|array $orders;
  40.     #[ORM\OneToMany(mappedBy'paymentMethod'targetEntityInvoice::class)]
  41.     private Collection $invoices;
  42.     #[ORM\Column(length255nullabletrue)]
  43.     private ?string $type null;
  44.     #[ORM\Column(length255nullabletrue)]
  45.     private ?string $secretKey null;
  46.     #[ORM\Column(length255nullabletrue)]
  47.     private ?string $publicKey null;
  48.     #[ORM\Column(nullabletrue)]
  49.     private array $displayOn = [];
  50.     public function __construct()
  51.     {
  52.         $this->payments = new ArrayCollection();
  53.         $this->orders = new ArrayCollection();
  54.         $this->invoices = new ArrayCollection();
  55.     }
  56.     public function __toString(): string
  57.     {
  58.         return (string)$this->name;
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getName(): ?string
  65.     {
  66.         return $this->name;
  67.     }
  68.     public function setName(string $name): self
  69.     {
  70.         $this->name $name;
  71.         return $this;
  72.     }
  73.     public function getImage(): ?string
  74.     {
  75.         return $this->image;
  76.     }
  77.     public function setImage(?string $image): self
  78.     {
  79.         $this->image $image;
  80.         return $this;
  81.     }
  82.     public function getDescription(): ?string
  83.     {
  84.         return $this->description;
  85.     }
  86.     public function setDescription(?string $description): self
  87.     {
  88.         $this->description $description;
  89.         return $this;
  90.     }
  91.     public function getCode(): ?string
  92.     {
  93.         return $this->code;
  94.     }
  95.     public function setCode(string $code): self
  96.     {
  97.         $this->code $code;
  98.         return $this;
  99.     }
  100.     public function getIsEnabled(): ?bool
  101.     {
  102.         return $this->isEnabled;
  103.     }
  104.     public function setIsEnabled(?bool $isEnabled): self
  105.     {
  106.         $this->isEnabled $isEnabled;
  107.         return $this;
  108.     }
  109.     public function getCreatedAt(): ?\DateTimeImmutable
  110.     {
  111.         return $this->createdAt;
  112.     }
  113.     public function setCreatedAt(?\DateTimeImmutable $createdAt): self
  114.     {
  115.         $this->createdAt $createdAt;
  116.         return $this;
  117.     }
  118.     public function getPosition(): ?int
  119.     {
  120.         return $this->position;
  121.     }
  122.     public function setPosition(?int $position): self
  123.     {
  124.         $this->position $position;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Collection|Payment[]
  129.      */
  130.     public function getPayments(): Collection
  131.     {
  132.         return $this->payments;
  133.     }
  134.     public function addPayment(Payment $payment): self
  135.     {
  136.         if (!$this->payments->contains($payment)) {
  137.             $this->payments[] = $payment;
  138.             $payment->setPaymentMethod($this);
  139.         }
  140.         return $this;
  141.     }
  142.     public function removePayment(Payment $payment): self
  143.     {
  144.         if ($this->payments->removeElement($payment)) {
  145.             // set the owning side to null (unless already changed)
  146.             if ($payment->getPaymentMethod() === $this) {
  147.                 $payment->setPaymentMethod(null);
  148.             }
  149.         }
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return Collection<int, Order>
  154.      */
  155.     public function getOrders(): Collection
  156.     {
  157.         return $this->orders;
  158.     }
  159.     public function addOrder(Order $order): self
  160.     {
  161.         if (!$this->orders->contains($order)) {
  162.             $this->orders[] = $order;
  163.             $order->setPaymentMethod($this);
  164.         }
  165.         return $this;
  166.     }
  167.     public function removeOrder(Order $order): self
  168.     {
  169.         if ($this->orders->removeElement($order)) {
  170.             // set the owning side to null (unless already changed)
  171.             if ($order->getPaymentMethod() === $this) {
  172.                 $order->setPaymentMethod(null);
  173.             }
  174.         }
  175.         return $this;
  176.     }
  177.     /**
  178.      * @return Collection<int, Invoice>
  179.      */
  180.     public function getInvoices(): Collection
  181.     {
  182.         return $this->invoices;
  183.     }
  184.     public function addInvoice(Invoice $invoice): self
  185.     {
  186.         if (!$this->invoices->contains($invoice)) {
  187.             $this->invoices->add($invoice);
  188.             $invoice->setPaymentMethod($this);
  189.         }
  190.         return $this;
  191.     }
  192.     public function removeInvoice(Invoice $invoice): self
  193.     {
  194.         if ($this->invoices->removeElement($invoice)) {
  195.             // set the owning side to null (unless already changed)
  196.             if ($invoice->getPaymentMethod() === $this) {
  197.                 $invoice->setPaymentMethod(null);
  198.             }
  199.         }
  200.         return $this;
  201.     }
  202.     public function getType(): ?string
  203.     {
  204.         return $this->type;
  205.     }
  206.     public function setType(?string $type): self
  207.     {
  208.         $this->type $type;
  209.         return $this;
  210.     }
  211.     public function getSecretKey(): ?string
  212.     {
  213.         return $this->secretKey;
  214.     }
  215.     public function setSecretKey(?string $secretKey): self
  216.     {
  217.         $this->secretKey $secretKey;
  218.         return $this;
  219.     }
  220.     public function getPublicKey(): ?string
  221.     {
  222.         return $this->publicKey;
  223.     }
  224.     public function setPublicKey(?string $publicKey): self
  225.     {
  226.         $this->publicKey $publicKey;
  227.         return $this;
  228.     }
  229.     public function getDisplayOn(): array
  230.     {
  231.         return $this->displayOn;
  232.     }
  233.     public function setDisplayOn(?array $displayOn): self
  234.     {
  235.         $this->displayOn $displayOn;
  236.         return $this;
  237.     }
  238. }