src/Entity/User.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. use Symfony\Component\Validator\Constraints as Assert;
  11. #[ORM\Entity(repositoryClassUserRepository::class)]
  12. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  13. class User implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     #[ORM\Id]
  16.     #[ORM\GeneratedValue]
  17.     #[ORM\Column]
  18.     private ?int $id null;
  19.     #[ORM\Column(length180uniquetrue)]
  20.     #[Assert\NotBlank(message'L\'email est obligatoire')]
  21.     #[Assert\Email(message'L\'email {{ value }} n\'est pas valide')]
  22.     private ?string $email null;
  23.     #[ORM\Column]
  24.     private array $roles = [];
  25.     /**
  26.      * @var string The hashed password
  27.      */
  28.     #[ORM\Column]
  29.     private ?string $password null;
  30.     #[ORM\Column(length50)]
  31.     #[Assert\NotBlank(message'Le nom complet est obligatoire')]
  32.     #[Assert\Length(min2max50minMessage'Le nom doit faire au moins {{ limit }} caractères'maxMessage'Le nom ne peut pas dépasser {{ limit }} caractères')]
  33.     private ?string $fullName null;
  34.     #[ORM\Column]
  35.     private ?\DateTimeImmutable $createdAt null;
  36.     
  37.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityEntreeStock::class)]
  38.     private Collection $entreeStocks;
  39.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntitySortieStock::class)]
  40.     private Collection $sortieStocks;
  41.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityProduit::class)]
  42.     private Collection $produits;
  43.     #[ORM\Column(length255)]
  44.     #[Assert\NotBlank(message'Le téléphone est obligatoire')]
  45.     #[Assert\Length(min8max20minMessage'Le téléphone doit faire au moins {{ limit }} caractères'maxMessage'Le téléphone ne peut pas dépasser {{ limit }} caractères')]
  46.     private ?string $telephone null;
  47.     #[ORM\Column(length255)]
  48.     #[Assert\NotBlank(message'L\'adresse est obligatoire')]
  49.     #[Assert\Length(min5max255minMessage'L\'adresse doit faire au moins {{ limit }} caractères'maxMessage'L\'adresse ne peut pas dépasser {{ limit }} caractères')]
  50.     private ?string $adress null;
  51.     #[ORM\OneToMany(mappedBy'user'targetEntityActionLog::class)]
  52.     private Collection $actionLogs;
  53.     #[ORM\OneToMany(mappedBy'vendeur'targetEntityVente::class)]
  54.     private Collection $ventes;
  55.     public function __construct() {
  56.         $this->createdAt= new \DateTimeImmutable();
  57.         $this->entreeStocks = new ArrayCollection();
  58.         $this->sortieStocks = new ArrayCollection();
  59.         $this->produits = new ArrayCollection();
  60.         $this->actionLogs = new ArrayCollection();
  61.         $this->ventes = new ArrayCollection();
  62.     }
  63.     public function getId(): ?int
  64.     {
  65.         return $this->id;
  66.     }
  67.     public function getEmail(): ?string
  68.     {
  69.         return $this->email;
  70.     }
  71.     public function setEmail(string $email): static
  72.     {
  73.         $this->email $email;
  74.         return $this;
  75.     }
  76.     /**
  77.      * A visual identifier that represents this user.
  78.      *
  79.      * @see UserInterface
  80.      */
  81.     public function getUserIdentifier(): string
  82.     {
  83.         return (string) $this->email;
  84.     }
  85.     /**
  86.      * @see UserInterface
  87.      */
  88.     public function getRoles(): array
  89.     {
  90.        
  91.         return array_unique($this->roles);
  92.     }
  93.     public function setRoles(array $roles): static
  94.     {
  95.         $this->roles $roles;
  96.         return $this;
  97.     }
  98.     /**
  99.      * @see PasswordAuthenticatedUserInterface
  100.      */
  101.     public function getPassword(): string
  102.     {
  103.         return $this->password;
  104.     }
  105.     public function setPassword(string $password): static
  106.     {
  107.         $this->password $password;
  108.         return $this;
  109.     }
  110.     /**
  111.      * @see UserInterface
  112.      */
  113.     public function eraseCredentials(): void
  114.     {
  115.         // If you store any temporary, sensitive data on the user, clear it here
  116.         // $this->plainPassword = null;
  117.     }
  118.     public function getFullName(): ?string
  119.     {
  120.         return $this->fullName;
  121.     }
  122.     public function setFullName(string $fullName): static
  123.     {
  124.         $this->fullName $fullName;
  125.         return $this;
  126.     }
  127.     public function getCreatedAt(): ?\DateTimeImmutable
  128.     {
  129.         return $this->createdAt;
  130.     }
  131.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  132.     {
  133.         $this->createdAt $createdAt;
  134.         return $this;
  135.     }
  136.    
  137.  
  138.     /**
  139.      * @return Collection<int, EntreeStock>
  140.      */
  141.     public function getEntreeStocks(): Collection
  142.     {
  143.         return $this->entreeStocks;
  144.     }
  145.     public function addEntreeStock(EntreeStock $entreeStock): static
  146.     {
  147.         if (!$this->entreeStocks->contains($entreeStock)) {
  148.             $this->entreeStocks->add($entreeStock);
  149.             $entreeStock->setUtilisateur($this);
  150.         }
  151.         return $this;
  152.     }
  153.     public function removeEntreeStock(EntreeStock $entreeStock): static
  154.     {
  155.         if ($this->entreeStocks->removeElement($entreeStock)) {
  156.             // set the owning side to null (unless already changed)
  157.             if ($entreeStock->getUtilisateur() === $this) {
  158.                 $entreeStock->setUtilisateur(null);
  159.             }
  160.         }
  161.         return $this;
  162.     }
  163.     /**
  164.      * @return Collection<int, SortieStock>
  165.      */
  166.     public function getSortieStocks(): Collection
  167.     {
  168.         return $this->sortieStocks;
  169.     }
  170.     public function addSortieStock(SortieStock $sortieStock): static
  171.     {
  172.         if (!$this->sortieStocks->contains($sortieStock)) {
  173.             $this->sortieStocks->add($sortieStock);
  174.             $sortieStock->setUtilisateur($this);
  175.         }
  176.         return $this;
  177.     }
  178.     public function removeSortieStock(SortieStock $sortieStock): static
  179.     {
  180.         if ($this->sortieStocks->removeElement($sortieStock)) {
  181.             // set the owning side to null (unless already changed)
  182.             if ($sortieStock->getUtilisateur() === $this) {
  183.                 $sortieStock->setUtilisateur(null);
  184.             }
  185.         }
  186.         return $this;
  187.     }
  188.     /**
  189.      * @return Collection<int, Produit>
  190.      */
  191.     public function getProduits(): Collection
  192.     {
  193.         return $this->produits;
  194.     }
  195.     public function addProduit(Produit $produit): static
  196.     {
  197.         if (!$this->produits->contains($produit)) {
  198.             $this->produits->add($produit);
  199.             $produit->setUtilisateur($this);
  200.         }
  201.         return $this;
  202.     }
  203.     public function removeProduit(Produit $produit): static
  204.     {
  205.         if ($this->produits->removeElement($produit)) {
  206.             // set the owning side to null (unless already changed)
  207.             if ($produit->getUtilisateur() === $this) {
  208.                 $produit->setUtilisateur(null);
  209.             }
  210.         }
  211.         return $this;
  212.     }
  213.   
  214.     public function getTelephone(): ?string
  215.     {
  216.         return $this->telephone;
  217.     }
  218.     public function setTelephone(string $telephone): static
  219.     {
  220.         $this->telephone $telephone;
  221.         return $this;
  222.     }
  223.     public function getAdress(): ?string
  224.     {
  225.         return $this->adress;
  226.     }
  227.     public function setAdress(string $adress): static
  228.     {
  229.         $this->adress $adress;
  230.         return $this;
  231.     }
  232.     /**
  233.      * @return Collection<int, ActionLog>
  234.      */
  235.     public function getActionLogs(): Collection
  236.     {
  237.         return $this->actionLogs;
  238.     }
  239.     public function addActionLog(ActionLog $actionLog): static
  240.     {
  241.         if (!$this->actionLogs->contains($actionLog)) {
  242.             $this->actionLogs->add($actionLog);
  243.             $actionLog->setUser($this);
  244.         }
  245.         return $this;
  246.     }
  247.     public function removeActionLog(ActionLog $actionLog): static
  248.     {
  249.         if ($this->actionLogs->removeElement($actionLog)) {
  250.             // set the owning side to null (unless already changed)
  251.             if ($actionLog->getUser() === $this) {
  252.                 $actionLog->setUser(null);
  253.             }
  254.         }
  255.         return $this;
  256.     }
  257.     /**
  258.      * @return Collection<int, Vente>
  259.      */
  260.     public function getVentes(): Collection
  261.     {
  262.         return $this->ventes;
  263.     }
  264.     public function addVente(Vente $vente): static
  265.     {
  266.         if (!$this->ventes->contains($vente)) {
  267.             $this->ventes->add($vente);
  268.             $vente->setVendeur($this);
  269.         }
  270.         return $this;
  271.     }
  272.     public function removeVente(Vente $vente): static
  273.     {
  274.         if ($this->ventes->removeElement($vente)) {
  275.             // set the owning side to null (unless already changed)
  276.             if ($vente->getVendeur() === $this) {
  277.                 $vente->setVendeur(null);
  278.             }
  279.         }
  280.         return $this;
  281.     }
  282. }