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