src/Entity/User.php line 16
- <?php
- namespace App\Entity;
- use App\Repository\UserRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
- use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
- use Symfony\Component\Security\Core\User\UserInterface;
- #[ORM\Entity(repositoryClass: UserRepository::class)]
- #[ORM\Table(name: '`users`')]
- #[UniqueEntity(fields: ['email'], message: 'Cet email existe déja')]
- class User implements UserInterface, PasswordAuthenticatedUserInterface
- {
- #[ORM\Id]
- #[ORM\GeneratedValue]
- #[ORM\Column()]
- private ?int $id = null;
- #[ORM\Column(length: 180, unique: true)]
- private ?string $telephone = null;
- #[ORM\Column]
- private array $roles = [];
- /**
- * @var string The hashed password
- */
- #[ORM\Column]
- private ?string $password = null;
- #[ORM\Column(length: 255)]
- private ?string $nom = null;
- #[ORM\Column(length: 255)]
- private ?string $prenoms = null;
- #[ORM\Column(length: 255, nullable: false)]
- private ?string $email = null;
- #[ORM\Column(length: 255, nullable: true)]
- private ?string $boutique = null;
- #[ORM\Column(length: 100)]
- private ?string $ville = null;
- #[ORM\Column(length: 20, nullable: true)]
- private ?string $telwhatsapp = null;
- #[ORM\OneToMany(mappedBy: 'createdBy', targetEntity: Articles::class)]
- private Collection $articles;
- #[ORM\Column]
- private ?bool $isVerified = null;
- #[ORM\ManyToOne(inversedBy: 'users')]
- private ?Boutiques $shop = null;
- #[ORM\OneToMany(mappedBy: 'vendeur', targetEntity: Immeubles::class)]
- private Collection $immeubles;
- #[ORM\OneToMany(mappedBy: 'vendeur', targetEntity: Vehicules::class)]
- private Collection $vehicules;
- #[ORM\OneToMany(mappedBy: 'utilisateur', targetEntity: Favoris::class)]
- private Collection $favoris;
- #[ORM\OneToMany(mappedBy: 'utilisateur', targetEntity: UserCode::class)]
- private Collection $userCodes;
- #[ORM\OneToMany(mappedBy: 'created_by', targetEntity: Services::class)]
- private Collection $services;
- public function __construct()
- {
- $this->articles = new ArrayCollection();
- $this->immeubles = new ArrayCollection();
- $this->vehicules = new ArrayCollection();
- $this->favoris = new ArrayCollection();
- $this->userCodes = new ArrayCollection();
- $this->services = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getTelephone(): ?string
- {
- return $this->telephone;
- }
- public function setTelephone(string $telephone): self
- {
- $this->telephone = $telephone;
- return $this;
- }
- /**
- * A visual identifier that represents this user.
- *
- * @see UserInterface
- */
- public function getUserIdentifier(): string
- {
- return (string) $this->telephone;
- }
- /**
- * @see UserInterface
- */
- public function getRoles(): array
- {
- $roles = $this->roles;
- // guarantee every user at least has ROLE_USER
- $roles[] = 'ROLE_USER';
- return array_unique($roles);
- }
- public function setRoles(array $roles): self
- {
- $this->roles = $roles;
- return $this;
- }
- /**
- * @see PasswordAuthenticatedUserInterface
- */
- public function getPassword(): string
- {
- return $this->password;
- }
- public function setPassword(string $password): self
- {
- $this->password = $password;
- return $this;
- }
- /**
- * @see UserInterface
- */
- public function eraseCredentials()
- {
- // If you store any temporary, sensitive data on the user, clear it here
- // $this->plainPassword = null;
- }
- public function getNom(): ?string
- {
- return $this->nom;
- }
- public function setNom(string $nom): self
- {
- $this->nom = $nom;
- return $this;
- }
- public function getPrenoms(): ?string
- {
- return $this->prenoms;
- }
- public function setPrenoms(string $prenoms): self
- {
- $this->prenoms = $prenoms;
- return $this;
- }
- public function getEmail(): ?string
- {
- return $this->email;
- }
- public function setEmail(?string $email): self
- {
- $this->email = $email;
- return $this;
- }
- public function getBoutique(): ?string
- {
- return $this->boutique;
- }
- public function setBoutique(?string $boutique): self
- {
- $this->boutique = $boutique;
- return $this;
- }
- public function getVille(): ?string
- {
- return $this->ville;
- }
- public function setVille(Villes $ville): self
- {
- $this->ville = $ville->getNom();
- return $this;
- }
- public function getTelwhatsapp(): ?string
- {
- return $this->telwhatsapp;
- }
- public function setTelwhatsapp(?string $telwhatsapp): self
- {
- $this->telwhatsapp = $telwhatsapp;
- return $this;
- }
- /**
- * @return Collection<int, Articles>
- */
- public function getArticles(): Collection
- {
- return $this->articles;
- }
- public function addArticle(Articles $article): self
- {
- if (!$this->articles->contains($article)) {
- $this->articles[] = $article;
- $article->setCreatedBy($this);
- }
- return $this;
- }
- public function removeArticle(Articles $article): self
- {
- if ($this->articles->removeElement($article)) {
- // set the owning side to null (unless already changed)
- if ($article->getCreatedBy() === $this) {
- $article->setCreatedBy(null);
- }
- }
- return $this;
- }
- public function isIsVerified(): ?bool
- {
- return $this->isVerified;
- }
- public function setIsVerified(bool $isVerified): self
- {
- $this->isVerified = $isVerified;
- return $this;
- }
- public function getShop(): ?Boutiques
- {
- return $this->shop;
- }
- public function setShop(?Boutiques $shop): self
- {
- $this->shop = $shop;
- return $this;
- }
- /**
- * @return Collection<int, Immeubles>
- */
- public function getImmeubles(): Collection
- {
- return $this->immeubles;
- }
- public function addImmeuble(Immeubles $immeuble): self
- {
- if (!$this->immeubles->contains($immeuble)) {
- $this->immeubles[] = $immeuble;
- $immeuble->setVendeur($this);
- }
- return $this;
- }
- public function removeImmeuble(Immeubles $immeuble): self
- {
- if ($this->immeubles->removeElement($immeuble)) {
- // set the owning side to null (unless already changed)
- if ($immeuble->getVendeur() === $this) {
- $immeuble->setVendeur(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Vehicules>
- */
- public function getVehicules(): Collection
- {
- return $this->vehicules;
- }
- public function addVehicule(Vehicules $vehicule): self
- {
- if (!$this->vehicules->contains($vehicule)) {
- $this->vehicules[] = $vehicule;
- $vehicule->setVendeur($this);
- }
- return $this;
- }
- public function removeVehicule(Vehicules $vehicule): self
- {
- if ($this->vehicules->removeElement($vehicule)) {
- // set the owning side to null (unless already changed)
- if ($vehicule->getVendeur() === $this) {
- $vehicule->setVendeur(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Favoris>
- */
- public function getFavoris(): Collection
- {
- return $this->favoris;
- }
- public function addFavori(Favoris $favori): self
- {
- if (!$this->favoris->contains($favori)) {
- $this->favoris->add($favori);
- $favori->setUtilisateur($this);
- }
- return $this;
- }
- public function removeFavori(Favoris $favori): self
- {
- if ($this->favoris->removeElement($favori)) {
- // set the owning side to null (unless already changed)
- if ($favori->getUtilisateur() === $this) {
- $favori->setUtilisateur(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, UserCode>
- */
- public function getUserCodes(): Collection
- {
- return $this->userCodes;
- }
- public function addUserCode(UserCode $userCode): static
- {
- if (!$this->userCodes->contains($userCode)) {
- $this->userCodes->add($userCode);
- $userCode->setUtilisateur($this);
- }
- return $this;
- }
- public function removeUserCode(UserCode $userCode): static
- {
- if ($this->userCodes->removeElement($userCode)) {
- // set the owning side to null (unless already changed)
- if ($userCode->getUtilisateur() === $this) {
- $userCode->setUtilisateur(null);
- }
- }
- return $this;
- }
- /**
- * @return Collection<int, Services>
- */
- public function getServices(): Collection
- {
- return $this->services;
- }
- public function addService(Services $service): static
- {
- if (!$this->services->contains($service)) {
- $this->services->add($service);
- $service->setCreatedBy($this);
- }
- return $this;
- }
- public function removeService(Services $service): static
- {
- if ($this->services->removeElement($service)) {
- // set the owning side to null (unless already changed)
- if ($service->getCreatedBy() === $this) {
- $service->setCreatedBy(null);
- }
- }
- return $this;
- }
- }