src/Entity/User.php line 15

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. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column]
  17.     private ?int $id null;
  18.     #[ORM\Column(length180uniquetrue)]
  19.     private ?string $email null;
  20.     #[ORM\Column]
  21.     private array $roles = [];
  22.     /**
  23.      * @var string The hashed password
  24.      */
  25.     #[ORM\Column]
  26.     private ?string $password null;
  27.     #[ORM\Column(length50)]
  28.     private ?string $fullName null;
  29.     #[ORM\Column]
  30.     private ?\DateTimeImmutable $createdAt null;
  31.     
  32.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityEntreeStock::class)]
  33.     private Collection $entreeStocks;
  34.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntitySortieStock::class)]
  35.     private Collection $sortieStocks;
  36.     #[ORM\OneToMany(mappedBy'utilisateur'targetEntityProduit::class)]
  37.     private Collection $produits;
  38.     #[ORM\Column(length255)]
  39.     private ?string $telephone null;
  40.     #[ORM\Column(length255)]
  41.     private ?string $adress null;
  42.     #[ORM\OneToMany(mappedBy'user'targetEntityActionLog::class)]
  43.     private Collection $actionLogs;
  44.     #[ORM\OneToOne(mappedBy'user'cascade: ['persist''remove'])]
  45.     private ?Livreur $livreur null;
  46.     #[ORM\ManyToOne(inversedBy'users')]
  47.     private ?Boutique $boutique null;
  48.     public function __construct() {
  49.         $this->createdAt= new \DateTimeImmutable();
  50.         $this->entreeStocks = new ArrayCollection();
  51.         $this->sortieStocks = new ArrayCollection();
  52.         $this->produits = new ArrayCollection();
  53.         $this->actionLogs = new ArrayCollection();
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getEmail(): ?string
  60.     {
  61.         return $this->email;
  62.     }
  63.     public function setEmail(string $email): static
  64.     {
  65.         $this->email $email;
  66.         return $this;
  67.     }
  68.     /**
  69.      * A visual identifier that represents this user.
  70.      *
  71.      * @see UserInterface
  72.      */
  73.     public function getUserIdentifier(): string
  74.     {
  75.         return (string) $this->email;
  76.     }
  77.     /**
  78.      * @see UserInterface
  79.      */
  80.     public function getRoles(): array
  81.     {
  82.        
  83.         return array_unique($this->roles);
  84.     }
  85.     public function setRoles(array $roles): static
  86.     {
  87.         $this->roles $roles;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @see PasswordAuthenticatedUserInterface
  92.      */
  93.     public function getPassword(): string
  94.     {
  95.         return $this->password;
  96.     }
  97.     public function setPassword(string $password): static
  98.     {
  99.         $this->password $password;
  100.         return $this;
  101.     }
  102.     /**
  103.      * @see UserInterface
  104.      */
  105.     public function eraseCredentials(): void
  106.     {
  107.         // If you store any temporary, sensitive data on the user, clear it here
  108.         // $this->plainPassword = null;
  109.     }
  110.     public function getFullName(): ?string
  111.     {
  112.         return $this->fullName;
  113.     }
  114.     public function setFullName(string $fullName): static
  115.     {
  116.         $this->fullName $fullName;
  117.         return $this;
  118.     }
  119.     public function getCreatedAt(): ?\DateTimeImmutable
  120.     {
  121.         return $this->createdAt;
  122.     }
  123.     public function setCreatedAt(\DateTimeImmutable $createdAt): static
  124.     {
  125.         $this->createdAt $createdAt;
  126.         return $this;
  127.     }
  128.    
  129.  
  130.     /**
  131.      * @return Collection<int, EntreeStock>
  132.      */
  133.     public function getEntreeStocks(): Collection
  134.     {
  135.         return $this->entreeStocks;
  136.     }
  137.     public function addEntreeStock(EntreeStock $entreeStock): static
  138.     {
  139.         if (!$this->entreeStocks->contains($entreeStock)) {
  140.             $this->entreeStocks->add($entreeStock);
  141.             $entreeStock->setUtilisateur($this);
  142.         }
  143.         return $this;
  144.     }
  145.     public function removeEntreeStock(EntreeStock $entreeStock): static
  146.     {
  147.         if ($this->entreeStocks->removeElement($entreeStock)) {
  148.             // set the owning side to null (unless already changed)
  149.             if ($entreeStock->getUtilisateur() === $this) {
  150.                 $entreeStock->setUtilisateur(null);
  151.             }
  152.         }
  153.         return $this;
  154.     }
  155.     /**
  156.      * @return Collection<int, SortieStock>
  157.      */
  158.     public function getSortieStocks(): Collection
  159.     {
  160.         return $this->sortieStocks;
  161.     }
  162.     public function addSortieStock(SortieStock $sortieStock): static
  163.     {
  164.         if (!$this->sortieStocks->contains($sortieStock)) {
  165.             $this->sortieStocks->add($sortieStock);
  166.             $sortieStock->setUtilisateur($this);
  167.         }
  168.         return $this;
  169.     }
  170.     public function removeSortieStock(SortieStock $sortieStock): static
  171.     {
  172.         if ($this->sortieStocks->removeElement($sortieStock)) {
  173.             // set the owning side to null (unless already changed)
  174.             if ($sortieStock->getUtilisateur() === $this) {
  175.                 $sortieStock->setUtilisateur(null);
  176.             }
  177.         }
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, Produit>
  182.      */
  183.     public function getProduits(): Collection
  184.     {
  185.         return $this->produits;
  186.     }
  187.     public function addProduit(Produit $produit): static
  188.     {
  189.         if (!$this->produits->contains($produit)) {
  190.             $this->produits->add($produit);
  191.             $produit->setUtilisateur($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeProduit(Produit $produit): static
  196.     {
  197.         if ($this->produits->removeElement($produit)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($produit->getUtilisateur() === $this) {
  200.                 $produit->setUtilisateur(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205.   
  206.     public function getTelephone(): ?string
  207.     {
  208.         return $this->telephone;
  209.     }
  210.     public function setTelephone(string $telephone): static
  211.     {
  212.         $this->telephone $telephone;
  213.         return $this;
  214.     }
  215.     public function getAdress(): ?string
  216.     {
  217.         return $this->adress;
  218.     }
  219.     public function setAdress(string $adress): static
  220.     {
  221.         $this->adress $adress;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @return Collection<int, ActionLog>
  226.      */
  227.     public function getActionLogs(): Collection
  228.     {
  229.         return $this->actionLogs;
  230.     }
  231.     public function addActionLog(ActionLog $actionLog): static
  232.     {
  233.         if (!$this->actionLogs->contains($actionLog)) {
  234.             $this->actionLogs->add($actionLog);
  235.             $actionLog->setUser($this);
  236.         }
  237.         return $this;
  238.     }
  239.     public function removeActionLog(ActionLog $actionLog): static
  240.     {
  241.         if ($this->actionLogs->removeElement($actionLog)) {
  242.             // set the owning side to null (unless already changed)
  243.             if ($actionLog->getUser() === $this) {
  244.                 $actionLog->setUser(null);
  245.             }
  246.         }
  247.         return $this;
  248.     }
  249.     public function getLivreur(): ?Livreur
  250.     {
  251.         return $this->livreur;
  252.     }
  253.     public function setLivreur(Livreur $livreur): static
  254.     {
  255.         // set the owning side of the relation if necessary
  256.         if ($livreur->getUser() !== $this) {
  257.             $livreur->setUser($this);
  258.         }
  259.         $this->livreur $livreur;
  260.         return $this;
  261.     }
  262.     public function getBoutique(): ?Boutique
  263.     {
  264.         return $this->boutique;
  265.     }
  266.     public function setBoutique(?Boutique $boutique): static
  267.     {
  268.         $this->boutique $boutique;
  269.         return $this;
  270.     }
  271. }