<?php
namespace App\Entity\Users;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Validator\Constraints AS Constraints;
use Symfony\Component\Validator\Constraints AS Assert;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Doctrine\ORM\Mapping AS ORM;
use Ramsey\Uuid\Uuid;
/**
* @ORM\Entity(repositoryClass="App\Repository\Users\UserRepository")
* @ORM\Table(name="users_user")
* @ORM\HasLifecycleCallbacks()
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="uuid")
* @Assert\Uuid
*/
protected $uuid;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime", nullable=false)
* @Assert\NotBlank
*/
private $created;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime", nullable=true)
*/
private $lastActive;
/**
* @ORM\Column(type="string", length=100, unique=true)
* @Constraints\Email()
* @Constraints\NotBlank()
*/
private $email;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $password;
/**
* @ORM\Column(type="string", length=60, nullable=true)
*/
private $name;
/**
* @ORM\ManyToOne(targetEntity=Group::class, inversedBy="users")
* @ORM\JoinColumn(nullable=false)
**/
private $group;
public function __construct()
{
// Generate UUID
$uuid = Uuid::uuid1();
$this->setUuid($uuid->toString());
// Defaults
$this->created = new \DateTime();
}
public function getId()
{
return $this->id;
}
public function setUuid($uuid)
{
$this->uuid = $uuid;
return $this;
}
public function getUuid()
{
return $this->uuid;
}
public function getRoles() : array
{
return ['ROLE_USER'];
}
public function hasRole($role)
{
return in_array($role, $this->getRoles());
}
public function getUserIdentifier() : string
{
return $this->email;
}
public function setPassword(string $password = null)
{
$this->password = $password;
}
public function getPassword(): ?string
{
return $this->password;
}
public function eraseCredentials()
{
}
public function setCreated(\DateTime $created)
{
$this->created = $created;
}
public function getCreated()
{
return $this->created;
}
public function setLastActive(\DateTime $lastActive)
{
$this->lastActive = $lastActive;
}
public function getLastActive()
{
return $this->lastActive;
}
public function getEmail()
{
return $this->email;
}
public function setEmail(string $email)
{
$this->email = $email;
}
public function getName()
{
return $this->name;
}
public function setName(string $name = null)
{
$this->name = $name;
}
/**
* Get the value of group
*/
public function getGroup()
{
return $this->group;
}
/**
* Set the value of group
*
* @return self
*/
public function setGroup($group)
{
$this->group = $group;
return $this;
}
}