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.     public function __construct()
  34.     {
  35.         $this->sales = new ArrayCollection();
  36.         $this->payments = new ArrayCollection();
  37.         $this->invoices = new ArrayCollection();
  38.         $this->giftVouchers = new ArrayCollection();
  39.     }
  40.     public function getSales(): Collection
  41.     {
  42.         return $this->sales;
  43.     }
  44.     public function addSale(Sales $sale): self
  45.     {
  46.         if (!$this->sales->contains($sale)) {
  47.             $this->sales[] = $sale;
  48.             $sale->setCustomer($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeSale(Sales $sale): self
  53.     {
  54.         if ($this->sales->removeElement($sale)) {
  55.             if ($sale->getCustomer() === $this) {
  56.                 $sale->setCustomer(null);
  57.             }
  58.         }
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getFullName(): ?string
  65.     {
  66.         return $this->fullName;
  67.     }
  68.     public function setFullName(string $fullName): self
  69.     {
  70.         $this->fullName $fullName;
  71.         return $this;
  72.     }
  73.     public function getPhone(): ?string
  74.     {
  75.         return $this->phone;
  76.     }
  77.     public function setPhone(?string $phone): self
  78.     {
  79.         $this->phone $phone;
  80.         return $this;
  81.     }
  82.     public function getAddress(): ?string
  83.     {
  84.         return $this->address;
  85.     }
  86.     public function setAddress(?string $address): self
  87.     {
  88.         $this->address $address;
  89.         return $this;
  90.     }
  91.     public function getEmail(): ?string
  92.     {
  93.         return $this->email;
  94.     }
  95.     public function setEmail(?string $email): self
  96.     {
  97.         $this->email $email;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection<int, Payment>
  102.      */
  103.     public function getPayments(): Collection
  104.     {
  105.         return $this->payments;
  106.     }
  107.     public function addPayment(Payment $payment): self
  108.     {
  109.         if (!$this->payments->contains($payment)) {
  110.             $this->payments[] = $payment;
  111.             $payment->setCustomer($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removePayment(Payment $payment): self
  116.     {
  117.         if ($this->payments->removeElement($payment)) {
  118.             // set the owning side to null (unless already changed)
  119.             if ($payment->getCustomer() === $this) {
  120.                 $payment->setCustomer(null);
  121.             }
  122.         }
  123.         return $this;
  124.     }
  125.     public function getInvoices(): ArrayCollection|PersistentCollection
  126.     {
  127.         return $this->invoices;
  128.     }
  129.     public function setInvoices(ArrayCollection|PersistentCollection $invoices): void
  130.     {
  131.         $this->invoices $invoices;
  132.     }
  133.     public function addInvoice(Invoice $invoice): self
  134.     {
  135.         $this->invoices->add($invoice);
  136.         return $this;
  137.     }
  138.     public function removeInvoice(Invoice $invoice): self
  139.     {
  140.         $this->invoices->removeElement($invoice);
  141.         return $this;
  142.     }
  143.     public function getCode(): ?string
  144.     {
  145.         return $this->code;
  146.     }
  147.     public function setCode(?string $code): static
  148.     {
  149.         $this->code $code;
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return Collection<int, GiftVoucher>
  154.      */
  155.     public function getGiftVouchers(): Collection
  156.     {
  157.         return $this->giftVouchers;
  158.     }
  159.     public function addGiftVoucher(GiftVoucher $giftVoucher): static
  160.     {
  161.         if (!$this->giftVouchers->contains($giftVoucher)) {
  162.             $this->giftVouchers->add($giftVoucher);
  163.             $giftVoucher->setCustomer($this);
  164.         }
  165.         return $this;
  166.     }
  167.     public function removeGiftVoucher(GiftVoucher $giftVoucher): static
  168.     {
  169.         if ($this->giftVouchers->removeElement($giftVoucher)) {
  170.             // set the owning side to null (unless already changed)
  171.             if ($giftVoucher->getCustomer() === $this) {
  172.                 $giftVoucher->setCustomer(null);
  173.             }
  174.         }
  175.         return $this;
  176.     }
  177. }