<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @ORM\Table(schema="metro_menu_engineering")
*/
class User implements UserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @var array
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\Column(type="integer")
*/
private $active;
/**
* @ORM\Column(type="string", length=255)
*/
private $first_name;
/**
* @ORM\Column(type="string", length=255)
*/
private $last_name;
/**
* @ORM\Column(type="string", length=255)
*/
private $language;
/**
* @ORM\Column(type="integer")
*/
private $country_id;
/**
* @ORM\Column(type="integer")
*/
private $user_role;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $export;
/**
* @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
*/
private $modified;
/**
* @ORM\Column(type="datetime", nullable=true, options={"default": "CURRENT_TIMESTAMP"})
*/
private $created;
/**
* @ORM\ManyToOne(targetEntity=Team::class, inversedBy="users")
*/
private $team;
public function __toString()
{
// TODO: ADD Country-Name to String
// $entityManager = $this->getDoctrine()->getManager();
// $country = $entityManager->getRepository(Country::class)->find($this->getCountryId());
// $countryName = $country->getCategory()->getName();
//return ($this->getFirstName() . " " . $this->getLastName() . " (" . $countryName . ")") ?: 'unnamed';
return ($this->getFirstName() . " " . $this->getLastName()) ?: 'unnamed';
}
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 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 UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getActive(): ?int
{
return $this->active;
}
public function setActive(int $active): self
{
$this->active = $active;
return $this;
}
public function getFirstName(): ?string
{
return $this->first_name;
}
public function setFirstName(string $first_name): self
{
$this->first_name = $first_name;
return $this;
}
public function getLastName(): ?string
{
return $this->last_name;
}
public function setLastName(string $last_name): self
{
$this->last_name = $last_name;
return $this;
}
public function getLanguage(): ?string
{
return $this->language;
}
public function setLanguage(string $language): self
{
$this->language = $language;
return $this;
}
public function getCountryId(): ?int
{
return $this->country_id;
}
public function setCountryId(int $country_id): self
{
$this->country_id = $country_id;
return $this;
}
public function getUserRole(): ?int
{
return $this->user_role;
}
public function setUserRole(int $user_role): self
{
$this->user_role = $user_role;
return $this;
}
public function getExport(): ?string
{
return $this->export;
}
public function setExport(?string $export): self
{
$this->export = $export;
return $this;
}
public function getModified(): ?\DateTimeInterface
{
return $this->modified;
}
public function setModified(?\DateTimeInterface $modified): self
{
$this->modified = $modified;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(?\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
public function getTeam(): ?Team
{
return $this->team;
}
public function setTeam(?Team $team): self
{
$this->team = $team;
return $this;
}
}