- <?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\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
- use Symfony\Component\Security\Core\User\UserInterface;
- /**
-  * @ORM\Entity(repositoryClass=UserRepository::class)
-  * @ORM\Table(name="`user`")
-  */
- class User implements UserInterface, PasswordAuthenticatedUserInterface
- {
-     
-     /**
-      * @ORM\OneToMany(targetEntity=Wishlist::class, mappedBy="user")
-      */
-     private $wishlists;
-     
-     /**
-      * @ORM\Id
-      * @ORM\GeneratedValue
-      * @ORM\Column(type="integer")
-      */
-     private $id;
-     /**
-      * @ORM\Column(type="string", length=180, unique=true)
-      */
-     private $email;
-     /**
-      * @ORM\Column(type="json")
-      */
-     private $roles = [];
-     /**
-      * @var string The hashed password
-      * @ORM\Column(type="string")
-      */
-     private $password;
-     public function getFullName(): string{
-         return $this->getFirstname().' '.$this->getLastname();
-     }
-     /**
-      * @ORM\Column(type="string", length=255)
-      */
-     private $firstname;
-     /**
-      * @ORM\Column(type="string", length=255)
-      */
-     private $lastname;
-     /**
-      * @ORM\OneToMany(targetEntity=Address::class, mappedBy="user")
-      */
-     private $addresses;
-     /**
-      * @ORM\OneToMany(targetEntity=Order::class, mappedBy="user")
-      */
-     private $orders;
-     public function __construct()
-     {
-         $this->addresses = new ArrayCollection();
-         $this->orders = new ArrayCollection();
-         $this->wishlists = new ArrayCollection();
-     }
-     public function getId(): ?int
-     {
-         return $this->id;
-     }
-     public function getEmail(): ?string
-     {
-         return $this->email;
-     }
-     public function setEmail(string $email): self
-     {
-         $this->email = $email;
-         return $this;
-     }
-     /**
-      * A visual identifier that represents this user.
-      *
-      * @see UserInterface
-      */
-     public function getUserIdentifier(): string
-     {
-         return (string) $this->email;
-     }
-     /**
-      * @deprecated since Symfony 5.3, use getUserIdentifier instead
-      */
-     public function getUsername(): string
-     {
-         return (string) $this->email;
-     }
-     /**
-      * @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;
-     }
-     /**
-      * Returning a salt is only needed, if you are not using a modern
-      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
-      *
-      * @see UserInterface
-      */
-     public function getSalt(): ?string
-     {
-         return null;
-     }
-     /**
-      * @see UserInterface
-      */
-     public function eraseCredentials()
-     {
-         // If you store any temporary, sensitive data on the user, clear it here
-         // $this->plainPassword = null;
-     }
-     public function getFirstname(): ?string
-     {
-         return $this->firstname;
-     }
-     public function setFirstname(string $firstname): self
-     {
-         $this->firstname = $firstname;
-         return $this;
-     }
-     public function getLastname(): ?string
-     {
-         return $this->lastname;
-     }
-     public function setLastname(string $lastname): self
-     {
-         $this->lastname = $lastname;
-         return $this;
-     }
-     /**
-      * @return Collection<int, Address>
-      */
-     public function getAddresses(): Collection
-     {
-         return $this->addresses;
-     }
-     public function addAddress(Address $address): self
-     {
-         if (!$this->addresses->contains($address)) {
-             $this->addresses[] = $address;
-             $address->setUser($this);
-         }
-         return $this;
-     }
-     public function removeAddress(Address $address): self
-     {
-         if ($this->addresses->removeElement($address)) {
-             // set the owning side to null (unless already changed)
-             if ($address->getUser() === $this) {
-                 $address->setUser(null);
-             }
-         }
-         return $this;
-     }
-     /**
-      * @return Collection<int, Order>
-      */
-     public function getOrders(): Collection
-     {
-         return $this->orders;
-     }
-     public function addOrder(Order $order): self
-     {
-         if (!$this->orders->contains($order)) {
-             $this->orders[] = $order;
-             $order->setUser($this);
-         }
-         return $this;
-     }
-     public function removeOrder(Order $order): self
-     {
-         if ($this->orders->removeElement($order)) {
-             // set the owning side to null (unless already changed)
-             if ($order->getUser() === $this) {
-                 $order->setUser(null);
-             }
-         }
-         return $this;
-     }
- }
-