<?php


namespace NPS\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @ORM\Entity
 * @ORM\Table(name="`user`", indexes={@ORM\Index(name="email_index", columns={"email"})})
 */
class UserEntity implements IEntity
{
    
    use TCreate;
    use TIdProperty;

    /**
     * @ORM\Column(type="string", name="username", length=70, nullable=false)
     * @var string
     */
    public $username;

    /**
     * @ORM\Column(type="string", name="email", length=150, nullable=false)
     * @var string
     */
    public $email;

    /**
     * @ORM\Column(type="string", name="password", length=150, nullable=true)
     * @var string
     */
    public $password;

    /**
     * @ORM\Column(type="string", name="roles", length=300, nullable=false)
     * @var string
     */
    public $roles;

    
    /**
     * @ORM\Column(type="datetime", name="date_registered", nullable=false)
     * @var DateTime
     */
    public $dateRegistered;

    /**
     * @ORM\Column(type="datetime", name="date_activated", nullable=true)
     * @var DateTime
     */
    public $dateActivated;

    /**
     * @ORM\Column(type="datetime", name="date_credentials_updated", nullable=true)
     * @var DateTime
     */
    public $dateCredentialsUpdated;
    
    /**
     * @ORM\Column(type="datetime", name="date_login", nullable=true)
     * @var DateTime
     */
    public $lastLogin;

    /**
     * @ORM\Column(type="string", name="salt", length=30, nullable=true)
     * @var string
     */
    public $salt;

    /**
     * @ORM\OneToMany(targetEntity="AccessGrantEntity", mappedBy="user", cascade={"persist"})
     * @var ArrayCollection
     */
    public $grants;

    public function __construct()
    {
        $this->dateRegistered = new \DateTime();
        $this->dateCredentialsUpdated = new \DateTime();
        $this->grants = new ArrayCollection();
    }
}

