src/Entity/Users.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\CreatedAtTrait;
  4. use App\Repository\UsersRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. /**
  12.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  13.  */
  14. #[ORM\Entity(repositoryClassUsersRepository::class)]
  15. class Users implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     use CreatedAtTrait;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type'integer')]
  21.     private $id;
  22.     #[ORM\Column(type'string'length180uniquetrue)]
  23.     private $email;
  24.     #[ORM\Column(length20nullabletrue)]
  25.     private ?string $mobilePhone null;
  26.     #[ORM\Column(length20nullabletrue)]
  27.     private ?string $phone null;
  28.     #[ORM\Column(type'json')]
  29.     private $roles = [];
  30.     #[ORM\Column(type'string')]
  31.     private $password;
  32.     #[ORM\Column(type'string'length100)]
  33.     private $lastname;
  34.     #[ORM\Column(type'string'length100)]
  35.     private $firstname;
  36.     #[ORM\Column(type'string'length255)]
  37.     private $address;
  38.     #[ORM\Column(type'string'length20)]
  39.     private $zipcode;
  40.     #[ORM\Column(type'string'length150)]
  41.     private $city;
  42.     #[ORM\Column(type'boolean')]
  43.     private $is_verified false;
  44.     #[ORM\Column(type'string'length100nullabletrue)]
  45.     private $resetToken;
  46.     #[ORM\OneToMany(mappedBy'users'targetEntityOrders::class)]
  47.     private $orders;
  48.     #[ORM\ManyToOne(inversedBy'usersEntreprise')]
  49.     #[ORM\JoinColumn(nullabletrue)]
  50.     private ?Entreprise $entreprise null;
  51.     #[ORM\ManyToOne(inversedBy'usersAgence')]
  52.     #[ORM\JoinColumn(nullabletrue)]
  53.     private ?Agence $agence null;
  54.     public function __construct()
  55.     {
  56.         $this->orders = new ArrayCollection();
  57.         $this->created_at = new \DateTimeImmutable();
  58.     }
  59.     public function getId(): ?int
  60.     {
  61.         return $this->id;
  62.     }
  63.     public function getEmail(): ?string
  64.     {
  65.         return $this->email;
  66.     }
  67.     public function setEmail(string $email): self
  68.     {
  69.         $this->email $email;
  70.         return $this;
  71.     }
  72.     /**
  73.      * A visual identifier that represents this user.
  74.      *
  75.      * @see UserInterface
  76.      */
  77.     public function getUserIdentifier(): string
  78.     {
  79.         return (string) $this->email;
  80.     }
  81.     /**
  82.      * @see UserInterface
  83.      */
  84.     public function getRoles(): array
  85.     {
  86.         $roles $this->roles;
  87.         // guarantee every user at least has ROLE_USER
  88.         $roles[] = 'ROLE_USER';
  89.         return array_unique($roles);
  90.     }
  91.     public function setRoles(array $roles): self
  92.     {
  93.         $this->roles $roles;
  94.         return $this;
  95.     }
  96.     /**
  97.      * @see PasswordAuthenticatedUserInterface
  98.      */
  99.     public function getPassword(): string
  100.     {
  101.         return $this->password;
  102.     }
  103.     public function setPassword(string $password): self
  104.     {
  105.         $this->password $password;
  106.         return $this;
  107.     }
  108.     /**
  109.      * @see UserInterface
  110.      */
  111.     public function eraseCredentials()
  112.     {
  113.         // If you store any temporary, sensitive data on the user, clear it here
  114.         // $this->plainPassword = null;
  115.     }
  116.     public function getLastname(): ?string
  117.     {
  118.         return $this->lastname;
  119.     }
  120.     public function setLastname(string $lastname): self
  121.     {
  122.         $this->lastname $lastname;
  123.         return $this;
  124.     }
  125.     public function getFirstname(): ?string
  126.     {
  127.         return $this->firstname;
  128.     }
  129.     public function setFirstname(string $firstname): self
  130.     {
  131.         $this->firstname $firstname;
  132.         return $this;
  133.     }
  134.     public function getAddress(): ?string
  135.     {
  136.         return $this->address;
  137.     }
  138.     public function setAddress(string $address): self
  139.     {
  140.         $this->address $address;
  141.         return $this;
  142.     }
  143.     public function getZipcode(): ?string
  144.     {
  145.         return $this->zipcode;
  146.     }
  147.     public function setZipcode(string $zipcode): self
  148.     {
  149.         $this->zipcode $zipcode;
  150.         return $this;
  151.     }
  152.     public function getCity(): ?string
  153.     {
  154.         return $this->city;
  155.     }
  156.     public function setCity(string $city): self
  157.     {
  158.         $this->city $city;
  159.         return $this;
  160.     }
  161.     public function getIsVerified(): ?bool
  162.     {
  163.         return $this->is_verified;
  164.     }
  165.     public function setIsVerified(bool $is_verified): self
  166.     {
  167.         $this->is_verified $is_verified;
  168.         return $this;
  169.     }
  170.     public function getResetToken(): ?string
  171.     {
  172.         return $this->resetToken;
  173.     }
  174.     public function setResetToken(?string $resetToken): self
  175.     {
  176.         $this->resetToken $resetToken;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return Collection|Orders[]
  181.      */
  182.     public function getOrders(): Collection
  183.     {
  184.         return $this->orders;
  185.     }
  186.     public function addOrder(Orders $order): self
  187.     {
  188.         if (!$this->orders->contains($order)) {
  189.             $this->orders[] = $order;
  190.             $order->setUsers($this);
  191.         }
  192.         return $this;
  193.     }
  194.     public function removeOrder(Orders $order): self
  195.     {
  196.         if ($this->orders->removeElement($order)) {
  197.             // set the owning side to null (unless already changed)
  198.             if ($order->getUsers() === $this) {
  199.                 $order->setUsers(null);
  200.             }
  201.         }
  202.         return $this;
  203.     }
  204.     public function getAgence(): ?Agence { return $this->agence; }
  205.     public function setAgence(?Agence $agence): static { $this->agence $agence; return $this; }
  206.     public function getEntreprise(): ?Entreprise { return $this->entreprise; }
  207.     public function setEntreprise(?Entreprise $entreprise): static { $this->entreprise $entreprise; return $this; }
  208.     public function getPhone(): ?string{ return $this->phone; }
  209.     public function setPhone(?string $phone): static { $this->phone $phone; return $this; }
  210.     public function getMobilePhone(): ?string{ return $this->mobilePhone; }
  211.     public function setMobilePhone(?string $mobilePhone): static { $this->mobilePhone $mobilePhone; return $this; }
  212. }