src/Entity/User.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. use App\Repository\UserRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Entity(repositoryClass=UserRepository::class)
  10.  */
  11. class User implements UserInterface
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $email;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $password;
  27.     /**
  28.      * @ORM\Column(type="text", nullable=true)
  29.      */
  30.     private $address;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity=Order::class, mappedBy="user")
  33.      */
  34.     private $orders;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $nom;
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $numero;
  43.     public function __construct()
  44.     {
  45.         $this->orders = new ArrayCollection();
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function getEmail(): ?string
  52.     {
  53.         return $this->email;
  54.     }
  55.     public function setEmail(string $email): self
  56.     {
  57.         $this->email $email;
  58.         return $this;
  59.     }
  60.     public function getPassword(): ?string
  61.     {
  62.         return $this->password;
  63.     }
  64.     public function setPassword(string $password): self
  65.     {
  66.         $this->password $password;
  67.         return $this;
  68.     }
  69.     public function getAddress(): ?string
  70.     {
  71.         return $this->address;
  72.     }
  73.     public function setAddress(?string $address): self
  74.     {
  75.         $this->address $address;
  76.         return $this;
  77.     }
  78.     public function getUsername()
  79.     {
  80.         return $this->username;
  81.     }
  82.     public function eraseCredentials()
  83.     {
  84.     }
  85.     public function getSalt()
  86.     {
  87.     }
  88.     public function getRoles()
  89.     {
  90.         return ['ROLE_USER'];
  91.     }
  92.     public function getUserIdentifier(): string
  93.     {
  94.         return $this->getEmail();
  95.     }
  96.     /**
  97.      * @return Collection<int, Order>
  98.      */
  99.     public function getOrders(): Collection
  100.     {
  101.         return $this->orders;
  102.     }
  103.     public function addOrder(Order $order): self
  104.     {
  105.         if (!$this->orders->contains($order)) {
  106.             $this->orders[] = $order;
  107.             $order->setUser($this);
  108.         }
  109.         return $this;
  110.     }
  111.     public function removeOrder(Order $order): self
  112.     {
  113.         if ($this->orders->removeElement($order)) {
  114.             // set the owning side to null (unless already changed)
  115.             if ($order->getUser() === $this) {
  116.                 $order->setUser(null);
  117.             }
  118.         }
  119.         return $this;
  120.     }
  121.     public function getNom(): ?string
  122.     {
  123.         return $this->nom;
  124.     }
  125.     public function setNom(string $nom): self
  126.     {
  127.         $this->nom $nom;
  128.         return $this;
  129.     }
  130.     public function getNumero(): ?string
  131.     {
  132.         return $this->numero;
  133.     }
  134.     public function setNumero(string $numero): self
  135.     {
  136.         $this->numero $numero;
  137.         return $this;
  138.     }
  139. }