src/Entity/User.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Security\Core\User\UserInterface;
  5. /**
  6.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  7.  * @ORM\Table(schema="metro_menu_engineering")
  8.  */
  9. class User implements UserInterface
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue(strategy="IDENTITY")
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=180, unique=true)
  19.      */
  20.     private $email;
  21.     /**
  22.      * @var array
  23.      */
  24.     private $roles = [];
  25.     /**
  26.      * @var string The hashed password
  27.      * @ORM\Column(type="string")
  28.      */
  29.     private $password;
  30.     /**
  31.      * @ORM\Column(type="integer")
  32.      */
  33.     private $active;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $first_name;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      */
  41.     private $last_name;
  42.     /**
  43.      * @ORM\Column(type="string", length=255)
  44.      */
  45.     private $language;
  46.     /**
  47.      * @ORM\Column(type="integer")
  48.      */
  49.     private $country_id;
  50.     /**
  51.      * @ORM\Column(type="integer")
  52.      */
  53.     private $user_role;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $export;
  58.     /**
  59.      * @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
  60.      */
  61.     private $modified;
  62.     /**
  63.      * @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
  64.      */
  65.     private $created;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=Team::class, inversedBy="users")
  68.      */
  69.     private $team;
  70.     public function __toString()
  71.     {
  72.         // TODO: ADD Country-Name to String
  73.         // $entityManager = $this->getDoctrine()->getManager();
  74.         // $country = $entityManager->getRepository(Country::class)->find($this->getCountryId());
  75.         // $countryName = $country->getCategory()->getName();
  76.         //return ($this->getFirstName() . " " . $this->getLastName() . " (" . $countryName . ")") ?: 'unnamed';
  77.         return ($this->getFirstName() . " " $this->getLastName()) ?: 'unnamed';
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getEmail(): ?string
  84.     {
  85.         return $this->email;
  86.     }
  87.     public function setEmail(string $email): self
  88.     {
  89.         $this->email $email;
  90.         return $this;
  91.     }
  92.     /**
  93.      * A visual identifier that represents this user.
  94.      *
  95.      * @see UserInterface
  96.      */
  97.     public function getUsername(): string
  98.     {
  99.         return (string) $this->email;
  100.     }
  101.     /**
  102.      * @see UserInterface
  103.      */
  104.     public function getRoles(): array
  105.     {
  106.         $roles $this->roles;
  107.         // guarantee every user at least has ROLE_USER
  108.         $roles[] = 'ROLE_USER';
  109.         return array_unique($roles);
  110.     }
  111.     public function setRoles(array $roles): self
  112.     {
  113.         $this->roles $roles;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @see UserInterface
  118.      */
  119.     public function getPassword(): string
  120.     {
  121.         return (string) $this->password;
  122.     }
  123.     public function setPassword(string $password): self
  124.     {
  125.         $this->password $password;
  126.         return $this;
  127.     }
  128.     /**
  129.      * @see UserInterface
  130.      */
  131.     public function getSalt()
  132.     {
  133.         // not needed when using the "bcrypt" algorithm in security.yaml
  134.     }
  135.     /**
  136.      * @see UserInterface
  137.      */
  138.     public function eraseCredentials()
  139.     {
  140.         // If you store any temporary, sensitive data on the user, clear it here
  141.         // $this->plainPassword = null;
  142.     }
  143.     public function getActive(): ?int
  144.     {
  145.         return $this->active;
  146.     }
  147.     public function setActive(int $active): self
  148.     {
  149.         $this->active $active;
  150.         return $this;
  151.     }
  152.     public function getFirstName(): ?string
  153.     {
  154.         return $this->first_name;
  155.     }
  156.     public function setFirstName(string $first_name): self
  157.     {
  158.         $this->first_name $first_name;
  159.         return $this;
  160.     }
  161.     public function getLastName(): ?string
  162.     {
  163.         return $this->last_name;
  164.     }
  165.     public function setLastName(string $last_name): self
  166.     {
  167.         $this->last_name $last_name;
  168.         return $this;
  169.     }
  170.     public function getLanguage(): ?string
  171.     {
  172.         return $this->language;
  173.     }
  174.     public function setLanguage(string $language): self
  175.     {
  176.         $this->language $language;
  177.         return $this;
  178.     }
  179.     public function getCountryId(): ?int
  180.     {
  181.         return $this->country_id;
  182.     }
  183.     public function setCountryId(int $country_id): self
  184.     {
  185.         $this->country_id $country_id;
  186.         return $this;
  187.     }
  188.     public function getUserRole(): ?int
  189.     {
  190.         return $this->user_role;
  191.     }
  192.     public function setUserRole(int $user_role): self
  193.     {
  194.         $this->user_role $user_role;
  195.         return $this;
  196.     }
  197.     public function getExport(): ?string
  198.     {
  199.         return $this->export;
  200.     }
  201.     public function setExport(?string $export): self
  202.     {
  203.         $this->export $export;
  204.         return $this;
  205.     }
  206.     public function getModified(): ?\DateTimeInterface
  207.     {
  208.         return $this->modified;
  209.     }
  210.     public function setModified(?\DateTimeInterface $modified): self
  211.     {
  212.         $this->modified $modified;
  213.         return $this;
  214.     }
  215.     public function getCreated(): ?\DateTimeInterface
  216.     {
  217.         return $this->created;
  218.     }
  219.     public function setCreated(?\DateTimeInterface $created): self
  220.     {
  221.         $this->created $created;
  222.         return $this;
  223.     }
  224.     public function getTeam(): ?Team
  225.     {
  226.         return $this->team;
  227.     }
  228.     public function setTeam(?Team $team): self
  229.     {
  230.         $this->team $team;
  231.         return $this;
  232.     }
  233. }