src/Entity/System/Employee.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. /**
  7.  * Class Employee
  8.  *
  9.  * @ORM\Entity(repositoryClass="App\Repository\System\EmployeeRepository")
  10.  *
  11.  * @ORM\Table(name="ps_employee")
  12.  */
  13. class Employee implements UserInterfacePasswordAuthenticatedUserInterface
  14. {
  15.     /**
  16.      * @var int
  17.      *
  18.      * @ORM\Id
  19.      *
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      *
  22.      * @ORM\Column(type="integer", name="id_employee", options={"unsigned":true})
  23.      */
  24.     private $id;
  25.     /**
  26.      * @var Profile
  27.      *
  28.      * @ORM\ManyToOne(targetEntity="Profile")
  29.      *
  30.      * @ORM\JoinColumn(name="id_profile", referencedColumnName="id_profile")
  31.      */
  32.     private $profile;
  33.     /**
  34.      * @var Language
  35.      *
  36.      * @ORM\ManyToOne(targetEntity="Language")
  37.      *
  38.      * @ORM\JoinColumn(name="id_lang", referencedColumnName="id_lang")
  39.      */
  40.     private $language;
  41.     /**
  42.      * @var string
  43.      *
  44.      * @ORM\Column(type="string", name="lastname", length=32)
  45.      */
  46.     private $lastname;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(type="string", name="firstname", length=32)
  51.      */
  52.     private $firstname;
  53.     /**
  54.      * @var string
  55.      *
  56.      * @ORM\Column(type="string", nullable=false, unique=true, length=128)
  57.      */
  58.     private $email;
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(type="string", name="passwd", length=128)
  63.      */
  64.     private $password;
  65.     /**
  66.      * @var \DateTime
  67.      *
  68.      * @ORM\Column(type="datetime", options={"default":"CURRENT_TIMESTAMP"}, name="last_passwd_gen")
  69.      */
  70.     private $passwordDate;
  71.     /**
  72.      * @var bool|null
  73.      *
  74.      * @ORM\Column(type="boolean", options={"unsigned":true, "default":0})
  75.      */
  76.     private $active;
  77.     /**
  78.      * @var bool
  79.      *
  80.      * @ORM\Column(type="boolean", columnDefinition="tinyint(1)", options={"default" : 0})
  81.      */
  82.     private $multifactorAuthEnabled;
  83.     /**
  84.      * @var bool
  85.      */
  86.     private $avatar false;
  87.     /**
  88.      * @return int
  89.      */
  90.     public function getId(): int
  91.     {
  92.         return $this->id;
  93.     }
  94.     /**
  95.      * @param int $id
  96.      */
  97.     public function setId(int $id): void
  98.     {
  99.         $this->id $id;
  100.     }
  101.     /**
  102.      * @return Profile
  103.      */
  104.     public function getProfile(): Profile
  105.     {
  106.         return $this->profile;
  107.     }
  108.     /**
  109.      * @param Profile $profile
  110.      */
  111.     public function setProfile(Profile $profile): void
  112.     {
  113.         $this->profile $profile;
  114.     }
  115.     /**
  116.      * @return Language
  117.      */
  118.     public function getLanguage(): Language
  119.     {
  120.         return $this->language;
  121.     }
  122.     /**
  123.      * @param Language $language
  124.      */
  125.     public function setLanguage(Language $language): self
  126.     {
  127.         $this->language $language;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return string
  132.      */
  133.     public function getLastname(): string
  134.     {
  135.         return $this->lastname;
  136.     }
  137.     /**
  138.      * @param string $lastname
  139.      */
  140.     public function setLastname(string $lastname): self
  141.     {
  142.         $this->lastname $lastname;
  143.         return $this;
  144.     }
  145.     /**
  146.      * @return string
  147.      */
  148.     public function getFirstname(): string
  149.     {
  150.         return $this->firstname;
  151.     }
  152.     /**
  153.      * @param string $firstname
  154.      *
  155.      * @return Employee
  156.      */
  157.     public function setFirstname(string $firstname): self
  158.     {
  159.         $this->firstname $firstname;
  160.         return $this;
  161.     }
  162.     /**
  163.      * @return string
  164.      */
  165.     public function getEmail(): string
  166.     {
  167.         return $this->email;
  168.     }
  169.     /**
  170.      * @param string $email
  171.      *
  172.      * @return Employee
  173.      */
  174.     public function setEmail(string $email): self
  175.     {
  176.         $this->email $email;
  177.         return $this;
  178.     }
  179.     /**
  180.      * @return string
  181.      */
  182.     public function getPassword(): string
  183.     {
  184.         return $this->password;
  185.     }
  186.     /**
  187.      * @param string $password
  188.      *
  189.      * @return Employee
  190.      */
  191.     public function setPassword(string $password): self
  192.     {
  193.         $this->password $password;
  194.         return $this;
  195.     }
  196.     /**
  197.      * @return \DateTime
  198.      */
  199.     public function getPasswordDate(): \DateTime
  200.     {
  201.         return $this->passwordDate;
  202.     }
  203.     /**
  204.      * @param \DateTime $passwordDate
  205.      *
  206.      * @return Employee
  207.      */
  208.     public function setPasswordDate(\DateTime $passwordDate): self
  209.     {
  210.         $this->passwordDate $passwordDate;
  211.         return $this;
  212.     }
  213.     /**
  214.      * @return bool|null
  215.      */
  216.     public function isActive(): ?bool
  217.     {
  218.         return $this->active;
  219.     }
  220.     /**
  221.      * @param bool|null $active
  222.      *
  223.      * @return Employee
  224.      */
  225.     public function setActive(?bool $active): self
  226.     {
  227.         $this->active $active;
  228.         return $this;
  229.     }
  230.     /**
  231.      * @return mixed
  232.      */
  233.     public function getRoles()
  234.     {
  235.         $roles = [];
  236.         foreach ($this->getProfile()->getRoles() as $role) {
  237.             $roleName $role->getName();
  238.             if (!in_array($roleName$rolestrue)) {
  239.                 $roles[] = $role->getName();
  240.             }
  241.         }
  242.         return $roles;
  243.     }
  244.     /**
  245.      * @return string|null
  246.      */
  247.     public function getSalt(): ?string
  248.     {
  249.         return null;
  250.     }
  251.     /**
  252.      * @return string
  253.      */
  254.     public function getUsername(): string
  255.     {
  256.         return $this->email;
  257.     }
  258.     /**
  259.      * @return string
  260.      */
  261.     public function getName(): string
  262.     {
  263.         return $this->firstname.' '.$this->lastname;
  264.     }
  265.     /**
  266.      * @return mixed
  267.      */
  268.     public function eraseCredentials()
  269.     {
  270.         // TODO: Implement eraseCredentials() method.
  271.     }
  272.     public function getUserIdentifier(): string
  273.     {
  274.         return (string)$this->getId();
  275.     }
  276.     /**
  277.      * @return bool
  278.      */
  279.     public function hasMultifactorAuthEnabled(): bool
  280.     {
  281.         return $this->multifactorAuthEnabled;
  282.     }
  283.     public function __toString()
  284.     {
  285.         return $this->firstname.' '.$this->lastname;
  286.     }
  287.     public function setMultifactorAuthEnabled(bool $multifactorAuthEnabled): Employee
  288.     {
  289.         $this->multifactorAuthEnabled $multifactorAuthEnabled;
  290.         return $this;
  291.     }
  292.     public function hasAvatar(): bool
  293.     {
  294.         return $this->avatar;
  295.     }
  296. }