<?php
namespace App\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface as SecurityUser;
/**
* Class User
*
* @ORM\Table(name="user")
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
*/
class User implements SecurityUser, \Serializable
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="firstname", type="string")
*/
public $firstname;
/**
* @var string
*
* @ORM\Column(name="lastname", type="string")
*/
public $lastname;
/**
* @var string
*
* @ORM\Column(name="password", type="string")
*/
public $password;
/**
* @var string
*
* @ORM\Column(name="email", type="string")
*/
public $email;
/**
* @var array
*
* @ORM\Column(name="roles", type="array")
*/
public $roles;
/**
* @var string
*
* @ORM\Column(name="enabled", type="boolean")
*/
public $enabled;
/**
* Many Users have Many Monnaies.
* @var ArrayCollection
* @ORM\ManyToMany(targetEntity="App\Entity\Monnaie", inversedBy="users")
* @ORM\JoinTable(name="users_monnaies")
*/
private $monnaies;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @var DateTime
*/
private $lastLogin;
/**
* User constructor.
*/
public function __construct() {
$this->enabled = true;
$this->roles[] = 'ROLE_USER';
$this->monnaies = new ArrayCollection();
$this->lastLogin = new DateTime();
}
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* @return string
*/
public function getFirstname(): ?string {
return $this->firstname;
}
/**
* @param string $firstname
*/
public function setFirstname( string $firstname ): void {
$this->firstname = $firstname;
}
/**
* @return string
*/
public function getLastname(): ?string {
return $this->lastname;
}
/**
* @param string $lastname
*/
public function setLastname( string $lastname ): void {
$this->lastname = $lastname;
}
/**
* @return string
*/
public function getPassword(): ?string {
return $this->password;
}
/**
* @param string $password
*/
public function setPassword( string $password ): void {
$this->password = $password;
}
/**
* @return string
*/
public function getEmail(): ?string {
return $this->email;
}
/**
* @param string $email
*/
public function setEmail( string $email ): void {
$this->email = $email;
}
/**
* @return array
*/
public function getRoles(): array {
return $this->roles;
}
/**
* @param array $roles
*/
public function setRoles( array $roles ): void {
$this->roles = $roles;
}
/**
* @return string
*/
public function getEnabled(): string {
return $this->enabled;
}
/**
* @param string $enabled
*/
public function setEnabled( string $enabled ): void {
$this->enabled = $enabled;
}
/**
* {@inheritdoc}
*/
public function updatePassword(string $passwordEncoded): void
{
$this->password = $passwordEncoded;
}
/**
* {@inheritdoc}
*/
public function enable(): void
{
$this->enabled = true;
}
/**
* {@inheritdoc}
*/
public function disable(): void
{
$this->enabled = false;
}
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function serialize()
{
return serialize([
$this->id,
$this->email,
$this->password,
]);
}
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function unserialize($serialized)
{
list(
$this->id,
$this->email,
$this->password
) = unserialize($serialized);
}
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function getSalt()
{
return;
}
/**
* {@inheritdoc}
*
* @codeCoverageIgnore
*/
public function eraseCredentials()
{
return;
}
public function getUsername() {
return $this->email;
}
public function __toString()
{
return $this->firstname.' '.$this->lastname;
}
/**
* @return ArrayCollection
*/
public function getMonnaies()
{
return $this->monnaies;
}
/**
* @param ArrayCollection $monnaies
*/
public function setMonnaies(ArrayCollection $monnaies): void
{
$this->monnaies = $monnaies;
}
/**
* @param Monnaie $monnay
*/
public function addMonnay(Monnaie $monnay)
{
$this->monnaies[] = $monnay;
}
/**
* @param Monnaie $monnay
*/
public function removeMonnay(Monnaie $monnay)
{
$this->monnaies->removeElement($monnay);
}
public function getNbMonnaies() {
return count($this->monnaies);
}
/**
* @return DateTime
*/
public function getLastLogin(): ?DateTime
{
return $this->lastLogin;
}
/**
* @param DateTime $lastLogin
*/
public function setLastLogin(DateTime $lastLogin): void
{
$this->lastLogin = $lastLogin;
}
}