src/Flexy/ShopBundle/Entity/Payment/PaymentMethod.php line 15
<?php
namespace App\Flexy\ShopBundle\Entity\Payment;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\ShopBundle\Entity\Accounting\Invoice;
use App\Flexy\ShopBundle\Entity\Order\Order;
use App\Flexy\ShopBundle\Repository\Payment\PaymentMethodRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: PaymentMethodRepository::class)]
class PaymentMethod implements \Stringable
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private ?string $name = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $image = null;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $description = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $code = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isEnabled = null;
#[ORM\Column(type: 'datetime_immutable', nullable: true)]
private ?\DateTimeImmutable $createdAt = null;
#[ORM\Column(type: 'integer', nullable: true)]
private ?int $position = null;
#[ORM\OneToMany(targetEntity: Payment::class, mappedBy: 'paymentMethod')]
private \Doctrine\Common\Collections\Collection|array $payments;
#[ORM\OneToMany(targetEntity: Order::class, mappedBy: 'paymentMethod', cascade: ['persist'])]
#[ORM\JoinColumn(nullable: true, onDelete: 'CASCADE')]
private \Doctrine\Common\Collections\Collection|array $orders;
#[ORM\OneToMany(mappedBy: 'paymentMethod', targetEntity: Invoice::class)]
private Collection $invoices;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $secretKey = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $publicKey = null;
#[ORM\Column(nullable: true)]
private array $displayOn = [];
public function __construct()
{
$this->payments = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->invoices = new ArrayCollection();
}
public function __toString(): string
{
return (string)$this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled(?bool $isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getPosition(): ?int
{
return $this->position;
}
public function setPosition(?int $position): self
{
$this->position = $position;
return $this;
}
/**
* @return Collection|Payment[]
*/
public function getPayments(): Collection
{
return $this->payments;
}
public function addPayment(Payment $payment): self
{
if (!$this->payments->contains($payment)) {
$this->payments[] = $payment;
$payment->setPaymentMethod($this);
}
return $this;
}
public function removePayment(Payment $payment): self
{
if ($this->payments->removeElement($payment)) {
// set the owning side to null (unless already changed)
if ($payment->getPaymentMethod() === $this) {
$payment->setPaymentMethod(null);
}
}
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setPaymentMethod($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getPaymentMethod() === $this) {
$order->setPaymentMethod(null);
}
}
return $this;
}
/**
* @return Collection<int, Invoice>
*/
public function getInvoices(): Collection
{
return $this->invoices;
}
public function addInvoice(Invoice $invoice): self
{
if (!$this->invoices->contains($invoice)) {
$this->invoices->add($invoice);
$invoice->setPaymentMethod($this);
}
return $this;
}
public function removeInvoice(Invoice $invoice): self
{
if ($this->invoices->removeElement($invoice)) {
// set the owning side to null (unless already changed)
if ($invoice->getPaymentMethod() === $this) {
$invoice->setPaymentMethod(null);
}
}
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): self
{
$this->type = $type;
return $this;
}
public function getSecretKey(): ?string
{
return $this->secretKey;
}
public function setSecretKey(?string $secretKey): self
{
$this->secretKey = $secretKey;
return $this;
}
public function getPublicKey(): ?string
{
return $this->publicKey;
}
public function setPublicKey(?string $publicKey): self
{
$this->publicKey = $publicKey;
return $this;
}
public function getDisplayOn(): array
{
return $this->displayOn;
}
public function setDisplayOn(?array $displayOn): self
{
$this->displayOn = $displayOn;
return $this;
}
}