Advertisement
Guest User

entity

a guest
Apr 7th, 2020
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.13 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8.  
  9. /**
  10.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  11.  * @UniqueEntity(fields={"username"}, message="Istnieje już konto o podanym loginie.")
  12.  */
  13. class User implements UserInterface
  14. {
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.  
  22.     /**
  23.      * @ORM\Column(type="string", length=180, unique=true)
  24.      */
  25.     private $username;
  26.  
  27.     /**
  28.      * @ORM\Column(type="json")
  29.      */
  30.     private $roles = [];
  31.  
  32.     /**
  33.      * @var string The hashed password
  34.      * @ORM\Column(type="string")
  35.      */
  36.     private $password;
  37.  
  38.     /**
  39.      * @ORM\Column(type="string")
  40.      */
  41.     private $email;
  42.  
  43.     /**
  44.      * @ORM\Column(type="boolean", nullable=true)
  45.      */
  46.     private $activated;
  47.  
  48.     /**
  49.      * @ORM\Column(type="datetime", nullable=true)
  50.      */
  51.     private $created;
  52.  
  53.     /**
  54.      * @ORM\Column(type="integer", nullable=true)
  55.      */
  56.     private $char_1;
  57.  
  58.     /**
  59.      * @ORM\Column(type="integer", nullable=true)
  60.      */
  61.     private $char_2;
  62.  
  63.     /**
  64.      * @ORM\Column(type="integer", nullable=true)
  65.      */
  66.     private $char_3;
  67.  
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.  
  73.     /**
  74.      * A visual identifier that represents this user.
  75.      *
  76.      * @see UserInterface
  77.      */
  78.     public function getUsername(): string
  79.     {
  80.         return (string) $this->username;
  81.     }
  82.  
  83.     public function setUsername(string $username): self
  84.     {
  85.         $this->username = $username;
  86.  
  87.         return $this;
  88.     }
  89.    
  90.  
  91.     /**
  92.      * @see UserInterface
  93.      */
  94.     public function getRoles(): array
  95.     {
  96.         $roles = $this->roles;
  97.         // guarantee every user at least has ROLE_USER
  98.         $roles[] = 'ROLE_USER';
  99.  
  100.         return array_unique($roles);
  101.     }
  102.  
  103.     public function setRoles(array $roles): self
  104.     {
  105.         $this->roles = $roles;
  106.  
  107.         return $this;
  108.     }
  109.  
  110.     /**
  111.      * @see UserInterface
  112.      */
  113.     public function getPassword(): string
  114.     {
  115.         return (string) $this->password;
  116.     }
  117.  
  118.     public function setPassword(string $password): self
  119.     {
  120.         $this->password = $password;
  121.  
  122.         return $this;
  123.     }
  124.  
  125.     /**
  126.      * @see UserInterface
  127.      */
  128.     public function getSalt()
  129.     {
  130.         // not needed when using the "bcrypt" algorithm in security.yaml
  131.     }
  132.  
  133.     /**
  134.      * @see UserInterface
  135.      */
  136.     public function eraseCredentials()
  137.     {
  138.         // If you store any temporary, sensitive data on the user, clear it here
  139.         // $this->plainPassword = null;
  140.     }
  141.  
  142.     /**
  143.      * @see UserInterface
  144.      */
  145.     public function getEmail(): string
  146.     {
  147.         return (string) $this->email;
  148.     }
  149.  
  150.     public function setEmail(string $email): self
  151.     {
  152.         $this->email = $email;
  153.  
  154.         return $this;
  155.     }
  156.  
  157.     public function getActivated(): ?bool
  158.     {
  159.         return $this->activated;
  160.     }
  161.  
  162.     public function setActivated(?bool $activated): self
  163.     {
  164.         $this->activated = $activated;
  165.  
  166.         return $this;
  167.     }
  168.  
  169.     public function getCreated(): ?\DateTimeInterface
  170.     {
  171.         return $this->created;
  172.     }
  173.  
  174.     public function setCreated(\DateTimeInterface $created): self
  175.     {
  176.         $this->created = $created;
  177.  
  178.         return $this;
  179.     }
  180.  
  181.     public function getChar1(): ?int
  182.     {
  183.         return $this->char_1;
  184.     }
  185.  
  186.     public function setChar1(?int $char_1): self
  187.     {
  188.         $this->char_1 = $char_1;
  189.  
  190.         return $this;
  191.     }
  192.  
  193.     public function getChar2(): ?int
  194.     {
  195.         return $this->char_2;
  196.     }
  197.  
  198.     public function setChar2(?int $char_2): self
  199.     {
  200.         $this->char_2 = $char_2;
  201.  
  202.         return $this;
  203.     }
  204.  
  205.     public function getChar3(): ?int
  206.     {
  207.         return $this->char_3;
  208.     }
  209.  
  210.     public function setChar3(?int $char_3): self
  211.     {
  212.         $this->char_3 = $char_3;
  213.  
  214.         return $this;
  215.     }
  216. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement