src/Entity/User.php line 18

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. /**
  11.  * @ORM\Entity(repositoryClass=UserRepository::class)
  12.  * @ORM\Table(name="`user`")
  13.  * @UniqueEntity(fields={"email"}, message="There is already an account with this email")
  14.  */
  15. class User implements UserInterfacePasswordAuthenticatedUserInterface
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="string", length=180, unique=true)
  25.      */
  26.     private $email;
  27.     /**
  28.      * @ORM\Column(type="json")
  29.      */
  30.     private $roles = [];
  31.     /**
  32.      * @var string The hashed password
  33.      * @ORM\Column(type="string")
  34.      */
  35.     private $password;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity=Sales::class, mappedBy="user")
  38.      */
  39.     private $sales;
  40.     /**
  41.      * @ORM\Column(type="string", length=255)
  42.      */
  43.     private $fname;
  44.     /**
  45.      * @ORM\Column(type="string", length=255, nullable=true)
  46.      */
  47.     private $lname;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $username;
  52.     /**
  53.      * @ORM\ManyToOne(targetEntity=Profile::class, inversedBy="users")
  54.      * @ORM\JoinColumn(nullable=false)
  55.      */
  56.     private $profile;
  57.     /**
  58.      * @ORM\Column(type="datetime")
  59.      */
  60.     private $creation_date;
  61.     /**
  62.      * @ORM\Column(type="datetime", nullable=true)
  63.      */
  64.     private $edition_date;
  65.     /**
  66.      * @ORM\ManyToMany(targetEntity="Shop", fetch="EAGER")
  67.      * @ORM\JoinTable(name="user_shop",
  68.      *      joinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")},
  69.      *      inverseJoinColumns={@ORM\JoinColumn(name="shop_id", referencedColumnName="id")}
  70.      *      )
  71.      */
  72.     private $userShops;
  73.     /**
  74.      * @ORM\ManyToOne(targetEntity=Shop::class)
  75.      */
  76.     private $currentshop;
  77.     /**
  78.      * @ORM\Column(type="string", length=255)
  79.      */
  80.     private $target;
  81.     /**
  82.      * @ORM\Column(type="boolean")
  83.      */
  84.     private $isSynch;
  85.     /**
  86.      * @ORM\Column(type="boolean")
  87.      */
  88.     private $deleted 0;
  89.     public function __construct()
  90.     {
  91.         $this->sales = new ArrayCollection();
  92.         $this->userShops = new ArrayCollection();
  93.     }
  94.     public function getId(): ?int
  95.     {
  96.         return $this->id;
  97.     }
  98.     public function getEmail(): ?string
  99.     {
  100.         return $this->email;
  101.     }
  102.     public function setEmail(string $email): self
  103.     {
  104.         $this->email $email;
  105.         return $this;
  106.     }
  107.     /**
  108.      * A visual identifier that represents this user.
  109.      *
  110.      * @see UserInterface
  111.      */
  112.     public function getUserIdentifier(): string
  113.     {
  114.         return (string) $this->username;
  115.     }
  116.     /**
  117.      * @deprecated since Symfony 5.3, use getUserIdentifier instead
  118.      */
  119.     public function getUsername(): string
  120.     {
  121.         return (string) $this->username;
  122.     }
  123.     /**
  124.      * @see UserInterface
  125.      */
  126.     public function getRoles(): array
  127.     {
  128.         $roles $this->roles;
  129.         // guarantee every user at least has ROLE_USER
  130.         $roles[] = 'ROLE_USER';
  131.         return array_unique($roles);
  132.     }
  133.     public function setRoles(array $roles): self
  134.     {
  135.         $this->roles $roles;
  136.         return $this;
  137.     }
  138.     /**
  139.      * @see PasswordAuthenticatedUserInterface
  140.      */
  141.     public function getPassword(): string
  142.     {
  143.         return $this->password;
  144.     }
  145.     public function setPassword(string $password): self
  146.     {
  147.         $this->password $password;
  148.         return $this;
  149.     }
  150.     /**
  151.      * Returning a salt is only needed, if you are not using a modern
  152.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  153.      *
  154.      * @see UserInterface
  155.      */
  156.     public function getSalt(): ?string
  157.     {
  158.         return null;
  159.     }
  160.     /**
  161.      * @see UserInterface
  162.      */
  163.     public function eraseCredentials()
  164.     {
  165.         // If you store any temporary, sensitive data on the user, clear it here
  166.         // $this->plainPassword = null;
  167.     }
  168.     /**
  169.      * @return Collection<int, Sales>
  170.      */
  171.     public function getSales(): Collection
  172.     {
  173.         return $this->sales;
  174.     }
  175.     public function addSale(Sales $sale): self
  176.     {
  177.         if (!$this->sales->contains($sale)) {
  178.             $this->sales[] = $sale;
  179.             $sale->setUser($this);
  180.         }
  181.         return $this;
  182.     }
  183.     public function removeSale(Sales $sale): self
  184.     {
  185.         if ($this->sales->removeElement($sale)) {
  186.             // set the owning side to null (unless already changed)
  187.             if ($sale->getUser() === $this) {
  188.                 $sale->setUser(null);
  189.             }
  190.         }
  191.         return $this;
  192.     }
  193.     public function getFname(): ?string
  194.     {
  195.         return $this->fname;
  196.     }
  197.     public function setFname(string $fname): self
  198.     {
  199.         $this->fname $fname;
  200.         return $this;
  201.     }
  202.     public function getLname(): ?string
  203.     {
  204.         return $this->lname;
  205.     }
  206.     public function setLname(?string $lname): self
  207.     {
  208.         $this->lname $lname;
  209.         return $this;
  210.     }
  211.     public function setUsername(?string $username): self
  212.     {
  213.         $this->username $username;
  214.         return $this;
  215.     }
  216.     public function getProfile(): ?Profile
  217.     {
  218.         return $this->profile;
  219.     }
  220.     public function setProfile(?Profile $profile): self
  221.     {
  222.         $this->profile $profile;
  223.         return $this;
  224.     }
  225.     public function getCreationDate(): ?\DateTimeInterface
  226.     {
  227.         return $this->creation_date;
  228.     }
  229.     public function setCreationDate(\DateTimeInterface $creation_date): self
  230.     {
  231.         $this->creation_date $creation_date;
  232.         return $this;
  233.     }
  234.     public function getEditionDate(): ?\DateTimeInterface
  235.     {
  236.         return $this->edition_date;
  237.     }
  238.     public function setEditionDate(?\DateTimeInterface $edition_date): self
  239.     {
  240.         $this->edition_date $edition_date;
  241.         return $this;
  242.     }
  243.     /**
  244.      * @return Collection<int, UserShop>
  245.      */
  246.     public function getUserShops(): Collection
  247.     {
  248.         return $this->userShops;
  249.     }
  250.     public function addUserShop(UserShop $userShop): self
  251.     {
  252.         if (!$this->userShops->contains($userShop)) {
  253.             $this->userShops[] = $userShop;
  254.             $userShop->setUser($this);
  255.         }
  256.         return $this;
  257.     }
  258.     public function removeUserShop(UserShop $userShop): self
  259.     {
  260.         if ($this->userShops->removeElement($userShop)) {
  261.             // set the owning side to null (unless already changed)
  262.             if ($userShop->getUser() === $this) {
  263.                 $userShop->setUser(null);
  264.             }
  265.         }
  266.         return $this;
  267.     }
  268.     /**
  269.      * @return mixed
  270.      */
  271.     public function getCurrentshop()
  272.     {
  273.         return $this->currentshop;
  274.     }
  275.     /**
  276.      * @param mixed $currentshop
  277.      */
  278.     public function setCurrentshop($currentshop): void
  279.     {
  280.         $this->currentshop $currentshop;
  281.     }
  282.     /**
  283.      * @return mixed
  284.      */
  285.     public function getTarget()
  286.     {
  287.         return $this->target;
  288.     }
  289.     /**
  290.      * @param mixed $target
  291.      */
  292.     public function setTarget($target): void
  293.     {
  294.         $this->target $target;
  295.     }
  296.     /**
  297.      * @return mixed
  298.      */
  299.     public function getisSynch()
  300.     {
  301.         return $this->isSynch;
  302.     }
  303.     /**
  304.      * @param mixed $isSynch
  305.      */
  306.     public function setisSynch($isSynch): void
  307.     {
  308.         $this->isSynch $isSynch;
  309.     }
  310.     /**
  311.      * @return mixed
  312.      */
  313.     public function getDeleted()
  314.     {
  315.         return $this->deleted;
  316.     }
  317.     /**
  318.      * @param mixed $deleted
  319.      */
  320.     public function setDeleted($deleted): void
  321.     {
  322.         $this->deleted $deleted;
  323.     }
  324. }