Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Entity;
- use ApiPlatform\Core\Annotation\ApiResource;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * @ApiResource()
- * @ORM\Table(name="app_users")
- * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
- */
- class User
- {
- /**
- * @ORM\Id()
- * @ORM\GeneratedValue()
- * @ORM\Column(type="integer")
- */
- private $id;
- /**
- * @ORM\Column(type="string", length=100)
- */
- private $username;
- /**
- * @ORM\Column(type="string", length=100)
- */
- private $password;
- /**
- * @ORM\Column(type="string", length=255)
- */
- private $email;
- /**
- * @ORM\Column(type="boolean")
- */
- private $isActive;
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getUsername(): ?string
- {
- return $this->username;
- }
- public function setUsername(string $username): self
- {
- $this->username = $username;
- return $this;
- }
- public function getPassword(): ?string
- {
- return $this->password;
- }
- public function setPassword(string $password): self
- {
- $this->password = $password;
- return $this;
- }
- public function getEmail(): ?string
- {
- return $this->email;
- }
- public function setEmail(string $email): self
- {
- $this->email = $email;
- return $this;
- }
- public function getIsActive(): ?bool
- {
- return $this->isActive;
- }
- public function setIsActive(bool $isActive): self
- {
- $this->isActive = $isActive;
- return $this;
- }
- public function __construct()
- {
- $this->isActive = true;
- // may not be needed, see section on salt below
- // $this->salt = md5(uniqid('', true));
- }
- public function getSalt()
- {
- // you *may* need a real salt depending on your encoder
- // see section on salt below
- return null;
- }
- public function getRoles()
- {
- return array('ROLE_USER');
- }
- public function eraseCredentials()
- {
- }
- /** @see \Serializable::serialize() */
- public function serialize()
- {
- return serialize(array(
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt,
- ));
- }
- /** @see \Serializable::unserialize() */
- public function unserialize($serialized)
- {
- list (
- $this->id,
- $this->username,
- $this->password,
- // see section on salt below
- // $this->salt
- ) = unserialize($serialized, array('allowed_classes' => false));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment