src/Entity/Customer.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\CustomerRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ORM\Entity(repositoryClassCustomerRepository::class)]
  11. #[UniqueEntity(fields: ['ice'] , message:"Ice existe déja merci de saisir un autre")]
  12. #[ApiResource]
  13. class Customer
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $fistName null;
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?string $lastName null;
  23.     #[ORM\Column(length255nullabletrue)]
  24.     private ?string $mail null;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $phone null;
  27.     #[ORM\OneToOne(targetEntityUser::class, cascade: ['persist''remove'])]
  28.     private ?User $user null;
  29.     #[ORM\Column(length255nullabletrue)]
  30.     private ?string $genre null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     private ?string $ice null;
  33.     #[ORM\Column(length255nullabletrue)]
  34.     private ?string $nomEntreprice null;
  35.     #[ORM\Column(length255nullabletrue)]
  36.     private ?string $profession null;
  37.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  38.     private ?\DateTimeInterface $dateNaissance null;
  39.     #[ORM\OneToMany(mappedBy'customer'targetEntityInvoice::class)]
  40.     private Collection $invoices;
  41.     public function __construct()
  42.     {
  43.         $this->invoices = new ArrayCollection();
  44.     }
  45.     public function __toString()
  46.     {
  47.         return $this->fistName.' '.$this->lastName;
  48.     }
  49.     public function getId(): ?int
  50.     {
  51.         return $this->id;
  52.     }
  53.     public function getFistName(): ?string
  54.     {
  55.         return $this->fistName;
  56.     }
  57.     public function setFistName(?string $fistName): self
  58.     {
  59.         $this->fistName $fistName;
  60.         return $this;
  61.     }
  62.     public function getLastName(): ?string
  63.     {
  64.         return $this->lastName;
  65.     }
  66.     public function setLastName(?string $lastName): self
  67.     {
  68.         $this->lastName $lastName;
  69.         return $this;
  70.     }
  71.     public function getMail(): ?string
  72.     {
  73.         return $this->mail;
  74.     }
  75.     public function setMail(?string $mail): self
  76.     {
  77.         $this->mail $mail;
  78.         return $this;
  79.     }
  80.     public function getPhone(): ?string
  81.     {
  82.         return $this->phone;
  83.     }
  84.     public function setPhone(?string $phone): self
  85.     {
  86.         $this->phone $phone;
  87.         return $this;
  88.     }
  89.     public function getUser(): ?User
  90.     {
  91.         return $this->user;
  92.     }
  93.     public function setUser(?User $user): self
  94.     {
  95.         $this->user $user;
  96.         return $this;
  97.     }
  98.     public function getGenre(): ?string
  99.     {
  100.         return $this->genre;
  101.     }
  102.     public function setGenre(?string $genre): self
  103.     {
  104.         $this->genre $genre;
  105.         return $this;
  106.     }
  107.     public function getIce(): ?string
  108.     {
  109.         return $this->ice;
  110.     }
  111.     public function setIce(?string $ice): self
  112.     {
  113.         $this->ice $ice;
  114.         return $this;
  115.     }
  116.     public function getNomEntreprice(): ?string
  117.     {
  118.         return $this->nomEntreprice;
  119.     }
  120.     public function setNomEntreprice(?string $nomEntreprice): self
  121.     {
  122.         $this->nomEntreprice $nomEntreprice;
  123.         return $this;
  124.     }
  125.     public function getProfession(): ?string
  126.     {
  127.         return $this->profession;
  128.     }
  129.     public function setProfession(?string $profession): self
  130.     {
  131.         $this->profession $profession;
  132.         return $this;
  133.     }
  134.     public function getDateNaissance(): ?\DateTimeInterface
  135.     {
  136.         return $this->dateNaissance;
  137.     }
  138.     public function setDateNaissance(?\DateTimeInterface $dateNaissance): self
  139.     {
  140.         $this->dateNaissance $dateNaissance;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return Collection<int, Invoice>
  145.      */
  146.     public function getInvoices(): Collection
  147.     {
  148.         return $this->invoices;
  149.     }
  150.     public function addInvoice(Invoice $invoice): self
  151.     {
  152.         if (!$this->invoices->contains($invoice)) {
  153.             $this->invoices->add($invoice);
  154.             $invoice->setCustomer($this);
  155.         }
  156.         return $this;
  157.     }
  158.     public function removeInvoice(Invoice $invoice): self
  159.     {
  160.         if ($this->invoices->removeElement($invoice)) {
  161.             // set the owning side to null (unless already changed)
  162.             if ($invoice->getCustomer() === $this) {
  163.                 $invoice->setCustomer(null);
  164.             }
  165.         }
  166.         return $this;
  167.     }
  168. }