Skip to content

Instantly share code, notes, and snippets.

@kamil161g
Created November 6, 2017 18:53
Show Gist options
  • Save kamil161g/47e7652bf8c1c986d347018ae12996ff to your computer and use it in GitHub Desktop.
Save kamil161g/47e7652bf8c1c986d347018ae12996ff to your computer and use it in GitHub Desktop.
<?php
namespace AppBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* users
*
* @ORM\Table(name="users")
* @ORM\Entity(repositoryClass="AppBundle\Repository\UsersRepository")
*/
class Users implements UserInterface
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="login", type="string", length=255, nullable=true, unique=true)
*
* @Assert\NotBlank()
*/
private $login;
/**
* @Assert\NotBlank()
* @Assert\Length(max=4096)
*/
private $plainPassword;
/**
* @var string
*
* @ORM\Column(name="pass", type="string", length=255)
*
* @Assert\Length(max=4096)
* @Assert\NotBlank()
*/
private $pass;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=255, unique=true)
*
* @Assert\NotBlank(
* message="To pole nie może być puste."
* )
* @Assert\Email()
*/
private $email;
/**
* @var int
*
* @ORM\Column(name="pin", type="integer")
*
* @Assert\Length(
* min="4",
* minMessage="Pin ma się składać z 4 cyfr.",
* max="4",
* maxMessage="Pin ma się składać z 4 cyfr."
* )
*/
private $pin;
/**
* @var string
*
* @ORM\Column(name="roles", type="string", length=255)
*/
private $roles='ROLE_USER';
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set login
*
* @param string $login
*
* @return Users
*/
public function setLogin($login)
{
$this->login = $login;
return $this;
}
/**
* Get login
*
* @return string
*/
public function getLogin()
{
return $this->login;
}
/**
* @return mixed
*/
public function getPlainPassword()
{
return $this->plainPassword;
}
/**
* @param $pass
*/
public function setPlainPassword($pass)
{
$this->plainPassword = $pass;
}
/**
* Set pass
*
* @param string $pass
*
* @return Users
*/
public function setPass($pass)
{
$this->pass = $pass;
return $this;
}
/**
* Get pass
*
* @return string
*/
public function getPass()
{
return $this->pass;
}
/**
* Set email
*
* @param string $email
*
* @return Users
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Get email
*
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* Set pin
*
* @param integer $pin
*
* @return Users
*/
public function setPin($pin)
{
$this->pin = $pin;
return $this;
}
/**
* Get pin
*
* @return int
*/
public function getPin()
{
return $this->pin;
}
/**
* Set roles
*
* @param string $roles
*
* @return Users
*/
public function setRoles($roles)
{
$this->roles = $roles;
return $this;
}
/**
* @return array
*/
public function getRoles()
{
return array($this->roles);
}
public function getSalt()
{
// you *may* need a real salt depending on your encoder
// see section on salt below
return null;
}
public function eraseCredentials()
{
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize(array(
$this->id,
$this->login,
$this->pass,
// see section on salt below
// $this->salt,
));
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
list (
$this->id,
$this->login,
$this->pass,
// see section on salt below
// $this->salt
) = unserialize($serialized);
}
public function getUsername()
{
return $this->login;
}
public function getPassword()
{
return $this->pass;
}
public function __construct()
{
$this->isActive = true;
// may not be needed, see section on salt below
// $this->salt = md5(uniqid('', true));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment