src/Entity/AppUser.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AppUserRepository;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * @ORM\Entity(repositoryClass=AppUserRepository::class)
  11.  * @UniqueEntity("email",message="Tento email je již zaregistrován")
  12.  */
  13. class AppUser implements UserInterface
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="IDENTITY")
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=180, unique=true)
  23.      * @Assert\Email(message="Zadejte platný email")
  24.      * @Assert\NotBlank(message="Zadejte Email")
  25.      */
  26.     private $email;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      * @Assert\NotNull(message="Zadejte platné křestní jméno")
  30.      * @Assert\NotBlank(message="Zadejte platné křestní jméno")
  31.      */
  32.     private $firstName;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      * @Assert\NotNull(message="Zadejte platné příjmení")
  36.      * @Assert\NotBlank(message="Zadejte platné příjmení")
  37.      */
  38.     private $lastName;
  39.     /**
  40.      * @var string
  41.      * @ORM\Column (name="street",nullable=true,type="string")
  42.      */
  43.     private $street;
  44.     /**
  45.      * @var string
  46.      * @ORM\Column (name="town",nullable=true,type="string")
  47.      */
  48.     private $town;
  49.     /**
  50.      * @var string
  51.      * @ORM\Column (name="postal_code",nullable=true,type="string")
  52.      *
  53.      * @Assert\Type(
  54.      *     type="numeric",
  55.      *     message="Zadejte validní PSČ",
  56.      *     groups={"Edit","Default"})
  57.      *
  58.      * @Assert\Length (
  59.      *     min=5,
  60.      *     max=5,
  61.      *     exactMessage="Zadejte validní PSČ",
  62.      *     minMessage="PSČ je příliš krátké",
  63.      *     maxMessage="PSČ je příliš dlouhé",
  64.      *     groups={"Edit","Default"})
  65.      */
  66.     private $postalCode;
  67.     /**
  68.      * @ORM\Column(type="string", length=255)
  69.      *
  70.      * @Assert\NotNull(
  71.      *     message="Zadejte platné telefoní číslo")
  72.      *
  73.      * @Assert\NotBlank(
  74.      *     message="Zadejte platné telefoní číslo")
  75.      *
  76.      * @Assert\Type(
  77.      *     type="numeric",
  78.      *     message="Zadejte validní telefoní číslo",
  79.      *     groups={"Default","Edit"})
  80.      *
  81.      */
  82.     private $telephone;
  83.     /**
  84.      * @var Department
  85.      * @ORM\ManyToOne(targetEntity="App\Entity\Department")
  86.      * @ORM\JoinColumn(name="department",referencedColumnName="id",nullable=true, onDelete="SET NULL")
  87.      */
  88.     private $department;
  89.     /**
  90.      * @ORM\Column(type="json")
  91.      */
  92.     private $roles = [];
  93.     /**
  94.      * @var string|null The hashed password
  95.      * @ORM\Column(type="string")
  96.      * @Assert\Regex(
  97.      *     "/^(?=.*[0-9])(?=.*[A-Z]).{8,30}$/",
  98.      *     message="Heslo musí obsahovat malé, velké písmeno a číslo. Minimální počet znaků je 8 max 30",
  99.      *     groups={"Default"})
  100.      *
  101.      * @Assert\NotBlank(message="Zadejte heslo")
  102.      */
  103.     private $password;
  104.     /**
  105.      * @var string|null
  106.      * @ORM\Column (name="sign",type="string",nullable=true)
  107.      */
  108.     private ?string $sign;
  109.     /**
  110.      * @var boolean
  111.      * @ORM\Column(type="boolean")
  112.      */
  113.     private $active false;
  114.     /**
  115.      * @var datetime
  116.      * @ORM\Column(type="datetime")
  117.      */
  118.     private $created;
  119.     /**
  120.      * @var string|null
  121.      * @ORM\Column(type="uuid",unique=true,nullable=true)
  122.      */
  123.     private $activationToken;
  124.     /**
  125.      * @var datetime|null
  126.      * @ORM\Column(type="datetime",nullable=true)
  127.      */
  128.     private $resendDateActivation;
  129.     /**
  130.      * @var string|null
  131.      * @ORM\Column(type="uuid",unique=true,nullable=true)
  132.      */
  133.     private $lostPasswordToken;
  134.     /**
  135.      * @var datetime|null
  136.      * @ORM\Column(type="datetime",nullable=true)
  137.      */
  138.     private $lostPasswordDate;
  139.     /**
  140.      * @var string|null
  141.      * @ORM\Column(type="string",nullable=true)
  142.      */
  143.     private ?string $accountPrefix;
  144.     /**
  145.      * @var string|null
  146.      * @ORM\Column(type="string",nullable=true)
  147.      *
  148.      * @Assert\NotBlank (
  149.      *     message="Číslo účtu nesmí být prázdné",
  150.      *      groups={"Edit"})
  151.      *
  152.      * @Assert\Regex(
  153.      *     pattern="/^[0-9]*$/",
  154.      *     message="Zadejte validní číslo účtu",
  155.      *     groups={"Edit"})
  156.      */
  157.     private ?string $accountNumber;
  158.     /**
  159.      * @var string|null
  160.      * @ORM\Column(type="string",nullable=true)
  161.      *
  162.      * @Assert\NotBlank (
  163.      *     message="Kód banky nesmí být prázdný",
  164.      *     groups={"Edit"})
  165.      *
  166.      * @Assert\Regex(
  167.      *     pattern="/^[0-9]*$/",
  168.      *     message="Zadejte validní 4 místný kód banky",
  169.      *     groups={"Edit"})
  170.      *
  171.      * @Assert\Length (
  172.      *     min=4,
  173.      *     max=4,
  174.      *     exactMessage="Kód banky musí být 4 místné číslo",
  175.      *     minMessage="Kód banky je příliš krátky. Kód banky musí být 4 místné číslo",
  176.      *     maxMessage="Kód banky je příliš Dlouhé. Kód banky musí být 4 místné číslo",
  177.      *     groups={"Edit"})
  178.      */
  179.     private ?string $bankCode;
  180.     /**
  181.      * @var date|null
  182.      * @ORM\Column(type="date",nullable=true)
  183.      */
  184.     private $birthDate;
  185.     /**
  186.      * @var date|null
  187.      * @ORM\Column(type="date",nullable=true)
  188.      */
  189.     private $passportDateOfPublication;
  190.     /**
  191.      * @var string|null
  192.      * @ORM\Column(type="string",nullable=true)
  193.      */
  194.     private ?string $passportPlaceOfPublication;
  195.     /**
  196.      * @var string|null
  197.      * @ORM\Column(type="string",nullable=true)
  198.      */
  199.     private ?string $passportNumber;
  200.     /**
  201.      * @var date|null
  202.      * @ORM\Column(type="date",nullable=true)
  203.      */
  204.     private $passportValidTo;
  205.     
  206.     private $salt "CzechRepublicGreatAgain";
  207.     public function getId(): ?int
  208.     {
  209.         return $this->id;
  210.     }
  211.     public function getEmail(): ?string
  212.     {
  213.         return $this->email;
  214.     }
  215.     public function setEmail(?string $email): self
  216.     {
  217.         $this->email $email;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return mixed
  222.      */
  223.     public function getFirstName()
  224.     {
  225.         return $this->firstName;
  226.     }
  227.     /**
  228.      * @param mixed $firstName
  229.      */
  230.     public function setFirstName($firstName): self
  231.     {
  232.         $this->firstName $firstName;
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return mixed
  237.      */
  238.     public function getLastName()
  239.     {
  240.         return $this->lastName;
  241.     }
  242.     /**
  243.      * @param mixed $lastName
  244.      */
  245.     public function setLastName($lastName): self
  246.     {
  247.         $this->lastName $lastName;
  248.         return $this;
  249.     }
  250.     /**
  251.      * @return mixed
  252.      */
  253.     public function getTelephone()
  254.     {
  255.         return $this->telephone;
  256.     }
  257.     /**
  258.      * @param mixed $telephone
  259.      */
  260.     public function setTelephone($telephone): self
  261.     {
  262.         $this->telephone $telephone;
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Department
  267.      */
  268.     public function getDepartment(): ?Department
  269.     {
  270.         return $this->department;
  271.     }
  272.     /**
  273.      * @param Department $department
  274.      */
  275.     public function setDepartment(?Department $department): self
  276.     {
  277.         $this->department $department;
  278.         return $this;
  279.     }
  280.     public function hasDepartment(string $department) {
  281.         if(is_null($this->department))
  282.         {
  283.             return false;
  284.         }
  285.         return $this->department->getName() === $department;
  286.     }
  287.     /**
  288.      * A visual identifier that represents this user.
  289.      *
  290.      * @see UserInterface
  291.      */
  292.     public function getUsername(): string
  293.     {
  294.         return (string) $this->email;
  295.     }
  296.     /**
  297.      * @see UserInterface
  298.      */
  299.     public function getRoles(): array
  300.     {
  301.         $roles $this->roles;
  302.         // guarantee every user at least has ROLE_USER
  303.         $roles[] = 'ROLE_USER';
  304.         return array_unique($roles);
  305.     }
  306.     public function setRoles(array $roles): self
  307.     {
  308.         $this->roles $roles;
  309.         return $this;
  310.     }
  311.     public function hasRole(string $role): bool {
  312.         return in_array($role,$this->roles);
  313.     }
  314.     /**
  315.      * @see UserInterface
  316.      */
  317.     public function getPassword(): ?string
  318.     {
  319.         return (string) $this->password;
  320.     }
  321.     public function setPassword(?string $password): self
  322.     {
  323.         $this->password $password;
  324.         return $this;
  325.     }
  326.     /**
  327.      * Returning a salt is only needed, if you are not using a modern
  328.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  329.      *
  330.      * @see UserInterface
  331.      */
  332.     public function getSalt(): ?string
  333.     {
  334.         return $this->salt;
  335.     }
  336.     /**
  337.      * @see UserInterface
  338.      */
  339.     public function eraseCredentials()
  340.     {
  341.         // If you store any temporary, sensitive data on the user, clear it here
  342.         // $this->plainPassword = null;
  343.     }
  344.     /**
  345.      * @return bool
  346.      */
  347.     public function isActive(): bool
  348.     {
  349.         return $this->active;
  350.     }
  351.     /**
  352.      * @param bool $active
  353.      */
  354.     public function setActive(bool $active): self
  355.     {
  356.         $this->active $active;
  357.         return $this;
  358.     }
  359.     /**
  360.      * @return DateTime
  361.      */
  362.     public function getCreated(): DateTime
  363.     {
  364.         return $this->created;
  365.     }
  366.     /**
  367.      * @param DateTime $created
  368.      */
  369.     public function setCreated(DateTime $created): self
  370.     {
  371.         $this->created $created;
  372.         return $this;
  373.     }
  374.     /**
  375.      * @return string|null
  376.      */
  377.     public function getActivationToken(): ?string
  378.     {
  379.         return $this->activationToken;
  380.     }
  381.     /**
  382.      * @param string|null $activationToken
  383.      */
  384.     public function setActivationToken(?string $activationToken): self
  385.     {
  386.         $this->activationToken $activationToken;
  387.         return $this;
  388.     }
  389.     /**
  390.      * @return string|null
  391.      */
  392.     public function getLostPasswordToken(): ?string
  393.     {
  394.         return $this->lostPasswordToken;
  395.     }
  396.     /**
  397.      * @param string|null $lostPasswordToken
  398.      */
  399.     public function setLostPasswordToken(?string $lostPasswordToken): self
  400.     {
  401.         $this->lostPasswordToken $lostPasswordToken;
  402.         return $this;
  403.     }
  404.     /**
  405.      * @return DateTime|null
  406.      */
  407.     public function getResendDateActivation(): ?DateTime
  408.     {
  409.         return $this->resendDateActivation;
  410.     }
  411.     /**
  412.      * @param DateTime|null $resendDateActivation
  413.      */
  414.     public function setResendDateActivation(?DateTime $resendDateActivation): self
  415.     {
  416.         $this->resendDateActivation $resendDateActivation;
  417.         return $this;
  418.     }
  419.     /**
  420.      * @return DateTime|null
  421.      */
  422.     public function getLostPasswordDate(): ?DateTime
  423.     {
  424.         return $this->lostPasswordDate;
  425.     }
  426.     /**
  427.      * @param DateTime|null $lostPasswordDate
  428.      */
  429.     public function setLostPasswordDate(?DateTime $lostPasswordDate): self
  430.     {
  431.         $this->lostPasswordDate $lostPasswordDate;
  432.         return $this;
  433.     }
  434.     /**
  435.      * @return string
  436.      */
  437.     public function getStreet(): ?string
  438.     {
  439.         return $this->street;
  440.     }
  441.     /**
  442.      * @param string $street
  443.      */
  444.     public function setStreet(string $street): self
  445.     {
  446.         $this->street $street;
  447.         return $this;
  448.     }
  449.     /**
  450.      * @return string
  451.      */
  452.     public function getTown(): ?string
  453.     {
  454.         return $this->town;
  455.     }
  456.     /**
  457.      * @param string $town
  458.      */
  459.     public function setTown(string $town): self
  460.     {
  461.         $this->town $town;
  462.         return $this;
  463.     }
  464.     /**
  465.      * @return string
  466.      */
  467.     public function getPostalCode(): ?string
  468.     {
  469.         return $this->postalCode;
  470.     }
  471.     /**
  472.      * @param string $postalCode
  473.      */
  474.     public function setPostalCode(string $postalCode): self
  475.     {
  476.         $this->postalCode $postalCode;
  477.         return $this;
  478.     }
  479.     /**
  480.      * @return string|null
  481.      */
  482.     public function getSign(): ?string
  483.     {
  484.         return $this->sign;
  485.     }
  486.     /**
  487.      * @param string|null $sign
  488.      */
  489.     public function setSign(?string $sign): self
  490.     {
  491.         $this->sign $sign;
  492.         return $this;
  493.     }
  494.     /**
  495.      * @return string|null
  496.      */
  497.     public function getAccountPrefix(): ?string
  498.     {
  499.         return $this->accountPrefix;
  500.     }
  501.     /**
  502.      * @param string|null $accountPrefix
  503.      */
  504.     public function setAccountPrefix(?string $accountPrefix): void
  505.     {
  506.         $this->accountPrefix $accountPrefix;
  507.     }
  508.     /**
  509.      * @return string|null
  510.      */
  511.     public function getAccountNumber(): ?string
  512.     {
  513.         return $this->accountNumber;
  514.     }
  515.     /**
  516.      * @param string|null $accountNumber
  517.      */
  518.     public function setAccountNumber(?string $accountNumber): void
  519.     {
  520.         $this->accountNumber $accountNumber;
  521.     }
  522.     /**
  523.      * @return string|null
  524.      */
  525.     public function getBankCode(): ?string
  526.     {
  527.         return $this->bankCode;
  528.     }
  529.     /**
  530.      * @param string|null $bankCode
  531.      */
  532.     public function setBankCode(?string $bankCode): self
  533.     {
  534.         $this->bankCode $bankCode;
  535.         return $this;
  536.     }
  537.     public function __toString()
  538.     {
  539.         return $this->firstName ' ' $this->lastName;
  540.     }
  541.     /**
  542.      * @return DateTime|null
  543.      */
  544.     public function getBirthDate(): ?DateTime
  545.     {
  546.         return $this->birthDate;
  547.     }
  548.     /**
  549.      * @param DateTime|null $birthDate
  550.      */
  551.     public function setBirthDate(?DateTime $birthDate): self
  552.     {
  553.         $this->birthDate $birthDate;
  554.         return $this;
  555.     }
  556.     /**
  557.      * @return DateTime|null
  558.      */
  559.     public function getPassportDateOfPublication(): ?DateTime
  560.     {
  561.         return $this->passportDateOfPublication;
  562.     }
  563.     /**
  564.      * @param DateTime|null $passportDateOfPublication
  565.      */
  566.     public function setPassportDateOfPublication(?DateTime $passportDateOfPublication): self
  567.     {
  568.         $this->passportDateOfPublication $passportDateOfPublication;
  569.         return $this;
  570.     }
  571.     /**
  572.      * @return DateTime|null
  573.      */
  574.     public function getPassportValidTo(): ?DateTime
  575.     {
  576.         return $this->passportValidTo;
  577.     }
  578.     /**
  579.      * @param DateTime|null $passportValidTo
  580.      */
  581.     public function setPassportValidTo(?DateTime $passportValidTo): self
  582.     {
  583.         $this->passportValidTo $passportValidTo;
  584.         return $this;
  585.     }
  586.     /**
  587.      * @return string|null
  588.      */
  589.     public function getPassportPlaceOfPublication(): ?string
  590.     {
  591.         return $this->passportPlaceOfPublication;
  592.     }
  593.     /**
  594.      * @param string|null $passportPlaceOfPublication
  595.      */
  596.     public function setPassportPlaceOfPublication(?string $passportPlaceOfPublication): self
  597.     {
  598.         $this->passportPlaceOfPublication $passportPlaceOfPublication;
  599.         return $this;
  600.     }
  601.     /**
  602.      * @return string|null
  603.      */
  604.     public function getPassportNumber(): ?string
  605.     {
  606.         return $this->passportNumber;
  607.     }
  608.     /**
  609.      * @param string|null $passportNumber
  610.      */
  611.     public function setPassportNumber(?string $passportNumber): self
  612.     {
  613.         $this->passportNumber $passportNumber;
  614.         return $this;
  615.     }
  616. }