<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use App\Validator\Constraints as AcmeAssert;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Security\Core\User\UserInterface;
use App\Entity\UserRole;
use JMS\Serializer\Annotation\Exclude;
/**
* @ORM\Entity
* @ORM\Table(name="users")
*/
class User implements UserInterface, \Serializable{
/**
* @ORM\Column(name="id", type="integer", length=11, options={"unsigned"=true})
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(name="username", type="string", length=255, unique=true)
* @Assert\NotBlank(
* message = "Enter a valid username."
* )
*/
private $username;
/**
* @ORM\Column(name="email", type="string", length=255, unique=true)
* @Assert\Email(
* message = "The email '{{ value }}' is not a valid email.",
* )
*/
private $email;
/**
* @ORM\Column(name="password", type="string", length=255)
* @Exclude
* @Assert\NotBlank(
* message = "Enter a valid password."
* )
*/
private $password;
/**
* @ORM\Column(name="is_active", type="boolean")
*/
private $is_active;
/**
* @ORM\Column(type="json")
* @Exclude
*/
private $roles = [];
/**
* @ORM\OneToOne(targetEntity="App\Entity\Staff", mappedBy="user", cascade={"persist", "remove"})
*/
private $staff;
public function getID() { return $this->id; }
public function getUsername() { return $this->username; }
public function setUsername($username) { $this->username = $username; }
public function getEmail() { return $this->email; }
public function setEmail($email) { $this->email = $email; }
public function getPassword() { return $this->password; }
public function setPassword($password) { $this->password = $password; }
public function getIsActive(): ?bool { return $this->is_active; }
public function setIsActive(bool $is_active): self { $this->is_active = $is_active; return $this; }
public function serialize() {
return serialize([
$this->id,
$this->username,
$this->password,
]);
}
public function unserialize($serialized) {
list (
$this->id,
$this->username,
$this->password
) = unserialize($serialized);
}
public function getSalt() {}
public function eraseCredentials() {}
public function getStaff(): ?Staff { return $this->staff; }
public function setStaff(Staff $staff): self
{
$this->staff = $staff;
// set the owning side of the relation if necessary
if ($this !== $staff->getUser()) {
$staff->setUser($this);
}
return $this;
}
/**
* @see UserInterface
*/
public function getRoles(): array { $roles = $this->roles; $roles[] = 'ROLE_USER'; return array_unique($roles); }
public function setRoles(array $roles): self { $this->roles = $roles; return $this; }
}