src/Entity/Customer.php line 11

  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.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $fullName null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $email null;
  18.     #[ORM\Column(length50nullabletrue)]
  19.     private ?string $phoneNumber null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $address null;
  22.     #[ORM\Column]
  23.     private ?float $credit null;
  24.     #[ORM\OneToMany(mappedBy'customer'targetEntityOrder::class)]
  25.     private Collection $orders;
  26.     public function __construct()
  27.     {
  28.         $this->orders = new ArrayCollection();
  29.         $this->credit 0;
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getFullName(): ?string
  36.     {
  37.         return $this->fullName;
  38.     }
  39.     public function setFullName(string $fullName): self
  40.     {
  41.         $this->fullName $fullName;
  42.         return $this;
  43.     }
  44.     public function getEmail(): ?string
  45.     {
  46.         return $this->email;
  47.     }
  48.     public function setEmail(?string $email): self
  49.     {
  50.         $this->email $email;
  51.         return $this;
  52.     }
  53.     public function getPhoneNumber(): ?string
  54.     {
  55.         return $this->phoneNumber;
  56.     }
  57.     public function setPhoneNumber(?string $phoneNumber): self
  58.     {
  59.         $this->phoneNumber $phoneNumber;
  60.         return $this;
  61.     }
  62.     public function getAddress(): ?string
  63.     {
  64.         return $this->address;
  65.     }
  66.     public function setAddress(?string $address): self
  67.     {
  68.         $this->address $address;
  69.         return $this;
  70.     }
  71.     public function getCredit(): ?float
  72.     {
  73.         return $this->credit;
  74.     }
  75.     public function setCredit(float $credit): self
  76.     {
  77.         $this->credit $credit;
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, Order>
  82.      */
  83.     public function getOrders(): Collection
  84.     {
  85.         return $this->orders;
  86.     }
  87.     public function addOrder(Order $order): self
  88.     {
  89.         if (!$this->orders->contains($order)) {
  90.             $this->orders->add($order);
  91.             $order->setCustomer($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeOrder(Order $order): self
  96.     {
  97.         if ($this->orders->removeElement($order)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($order->getCustomer() === $this) {
  100.                 $order->setCustomer(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105.     public function __toString(): string
  106.     {
  107.         return $this->fullName;
  108.     }
  109. }