src/Entity/Customer.php line 11

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. #[ORM\Entity(repositoryClassCustomerRepository::class)]
  8. class Customer
  9. {
  10.     use IdentifiableTrait;
  11.     #[ORM\Column(length255)]
  12.     private ?string $name null;
  13.     #[ORM\OneToMany(mappedBy'customer'targetEntityInvoice::class)]
  14.     private Collection $invoices;
  15.     #[ORM\Column(length255)]
  16.     private ?string $code null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $email null;
  19.     #[ORM\ManyToOne(inversedBy'customers')]
  20.     private ?CustomerCategory $category null;
  21.     public function __construct()
  22.     {
  23.         $this->invoices = new ArrayCollection();
  24.     }
  25.     public function __toString(): string
  26.     {
  27.         return $this->getName();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getName(): ?string
  34.     {
  35.         return $this->name;
  36.     }
  37.     public function setName(string $name): self
  38.     {
  39.         $this->name $name;
  40.         return $this;
  41.     }
  42.     /**
  43.      * @return Collection<int, Invoice>
  44.      */
  45.     public function getInvoices(): Collection
  46.     {
  47.         return $this->invoices;
  48.     }
  49.     public function addInvoice(Invoice $invoice): self
  50.     {
  51.         if (!$this->invoices->contains($invoice)) {
  52.             $this->invoices->add($invoice);
  53.             $invoice->setCustomer($this);
  54.         }
  55.         return $this;
  56.     }
  57.     public function removeInvoice(Invoice $invoice): self
  58.     {
  59.         if ($this->invoices->removeElement($invoice)) {
  60.             // set the owning side to null (unless already changed)
  61.             if ($invoice->getCustomer() === $this) {
  62.                 $invoice->setCustomer(null);
  63.             }
  64.         }
  65.         return $this;
  66.     }
  67.     public function getCode(): ?string
  68.     {
  69.         return $this->code;
  70.     }
  71.     public function setCode(string $code): self
  72.     {
  73.         $this->code $code;
  74.         return $this;
  75.     }
  76.     public function getEmail(): ?string
  77.     {
  78.         return $this->email;
  79.     }
  80.     public function setEmail(?string $email): self
  81.     {
  82.         $this->email $email;
  83.         return $this;
  84.     }
  85.     public function getCategory(): ?CustomerCategory
  86.     {
  87.         return $this->category;
  88.     }
  89.     public function setCategory(?CustomerCategory $category): self
  90.     {
  91.         $this->category $category;
  92.         return $this;
  93.     }
  94. }