src/Entity/Customer.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CustomerRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Doctrine\ORM\PersistentCollection;
  8. #[ORM\Entity(repositoryClassCustomerRepository::class)]
  9. class Customer extends BaseEntity
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type'integer')]
  14.     private $id;
  15.     #[ORM\Column(type'string'length255)]
  16.     private $fullName;
  17.     #[ORM\Column(type'string'length255nullabletrue)]
  18.     private $phone;
  19.     #[ORM\Column(type'string'length255nullabletrue)]
  20.     private $address;
  21.     #[ORM\Column(type'string'length255nullabletrue)]
  22.     private $email;
  23.     #[ORM\OneToMany(mappedBy'customer'targetEntitySales::class, cascade: ['persist''remove'])]
  24.     private $sales;
  25.     #[ORM\OneToMany(mappedBy'customer'targetEntityInvoice::class, cascade: ['persist''remove'])]
  26.     private $invoices;
  27.     #[ORM\OneToMany(mappedBy'customer'targetEntityPayment::class)]
  28.     private $payments;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $code null;
  31.     #[ORM\OneToMany(mappedBy'customer'targetEntityGiftVoucher::class)]
  32.     private Collection $giftVouchers;
  33.     #[ORM\Column(type'boolean'options: ['default' => false])]
  34.     private ?bool $isInternal false;
  35.     #[ORM\ManyToOne(targetEntityCompany::class)]
  36.     #[ORM\JoinColumn(nullabletrueonDelete'CASCADE')]
  37.     private ?Company $linkedCompany null;
  38.     public function __construct()
  39.     {
  40.         $this->sales = new ArrayCollection();
  41.         $this->payments = new ArrayCollection();
  42.         $this->invoices = new ArrayCollection();
  43.         $this->giftVouchers = new ArrayCollection();
  44.     }
  45.     public function getSales(): Collection
  46.     {
  47.         return $this->sales;
  48.     }
  49.     public function addSale(Sales $sale): self
  50.     {
  51.         if (!$this->sales->contains($sale)) {
  52.             $this->sales[] = $sale;
  53.             $sale->setCustomer($this);
  54.         }
  55.         return $this;
  56.     }
  57.     public function removeSale(Sales $sale): self
  58.     {
  59.         if ($this->sales->removeElement($sale)) {
  60.             if ($sale->getCustomer() === $this) {
  61.                 $sale->setCustomer(null);
  62.             }
  63.         }
  64.         return $this;
  65.     }
  66.     public function getId(): ?int
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function getFullName(): ?string
  71.     {
  72.         return $this->fullName;
  73.     }
  74.     public function setFullName(string $fullName): self
  75.     {
  76.         $this->fullName $fullName;
  77.         return $this;
  78.     }
  79.     public function getPhone(): ?string
  80.     {
  81.         return $this->phone;
  82.     }
  83.     public function setPhone(?string $phone): self
  84.     {
  85.         $this->phone $phone;
  86.         return $this;
  87.     }
  88.     public function getAddress(): ?string
  89.     {
  90.         return $this->address;
  91.     }
  92.     public function setAddress(?string $address): self
  93.     {
  94.         $this->address $address;
  95.         return $this;
  96.     }
  97.     public function getEmail(): ?string
  98.     {
  99.         return $this->email;
  100.     }
  101.     public function setEmail(?string $email): self
  102.     {
  103.         $this->email $email;
  104.         return $this;
  105.     }
  106.     /**
  107.      * @return Collection<int, Payment>
  108.      */
  109.     public function getPayments(): Collection
  110.     {
  111.         return $this->payments;
  112.     }
  113.     public function addPayment(Payment $payment): self
  114.     {
  115.         if (!$this->payments->contains($payment)) {
  116.             $this->payments[] = $payment;
  117.             $payment->setCustomer($this);
  118.         }
  119.         return $this;
  120.     }
  121.     public function removePayment(Payment $payment): self
  122.     {
  123.         if ($this->payments->removeElement($payment)) {
  124.             // set the owning side to null (unless already changed)
  125.             if ($payment->getCustomer() === $this) {
  126.                 $payment->setCustomer(null);
  127.             }
  128.         }
  129.         return $this;
  130.     }
  131.     public function getInvoices(): ArrayCollection|PersistentCollection
  132.     {
  133.         return $this->invoices;
  134.     }
  135.     public function setInvoices(ArrayCollection|PersistentCollection $invoices): void
  136.     {
  137.         $this->invoices $invoices;
  138.     }
  139.     public function addInvoice(Invoice $invoice): self
  140.     {
  141.         $this->invoices->add($invoice);
  142.         return $this;
  143.     }
  144.     public function removeInvoice(Invoice $invoice): self
  145.     {
  146.         $this->invoices->removeElement($invoice);
  147.         return $this;
  148.     }
  149.     public function getCode(): ?string
  150.     {
  151.         return $this->code;
  152.     }
  153.     public function setCode(?string $code): static
  154.     {
  155.         $this->code $code;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection<int, GiftVoucher>
  160.      */
  161.     public function getGiftVouchers(): Collection
  162.     {
  163.         return $this->giftVouchers;
  164.     }
  165.     public function addGiftVoucher(GiftVoucher $giftVoucher): static
  166.     {
  167.         if (!$this->giftVouchers->contains($giftVoucher)) {
  168.             $this->giftVouchers->add($giftVoucher);
  169.             $giftVoucher->setCustomer($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeGiftVoucher(GiftVoucher $giftVoucher): static
  174.     {
  175.         if ($this->giftVouchers->removeElement($giftVoucher)) {
  176.             // set the owning side to null (unless already changed)
  177.             if ($giftVoucher->getCustomer() === $this) {
  178.                 $giftVoucher->setCustomer(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     public function isInternal(): ?bool
  184.     {
  185.         return $this->isInternal;
  186.     }
  187.     public function setIsInternal(bool $isInternal): self
  188.     {
  189.         $this->isInternal $isInternal;
  190.         return $this;
  191.     }
  192.     public function getLinkedCompany(): ?Company
  193.     {
  194.         return $this->linkedCompany;
  195.     }
  196.     public function setLinkedCompany(?Company $linkedCompany): self
  197.     {
  198.         $this->linkedCompany $linkedCompany;
  199.         return $this;
  200.     }
  201. }