src/Entity/User/User.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\User;
  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.  * @ORM\Table(name="user")
  8.  * @ORM\Entity(repositoryClass="App\Entity\User\UserRepository")
  9.  * @ORM\HasLifecycleCallbacks()
  10.  */
  11. class User implements UserInterfacePasswordAuthenticatedUserInterface
  12. {
  13.     /**
  14.      * @ORM\Column(type="integer")
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     protected $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     protected $photo;
  23.     /**
  24.      * @ORM\Column(type="string", length=100)
  25.      */
  26.     protected $firstname;
  27.     /**
  28.      * @ORM\Column(type="string", length=100)
  29.      */
  30.     protected $lastname;
  31.     /**
  32.      * @var string
  33.      *
  34.      * @ORM\Column(name="email", type="string", length=255, nullable=true)
  35.      */
  36.     private $email;
  37.     
  38.     /**
  39.      * @var string
  40.      *
  41.      * @ORM\Column(name="username", type="string", length=255, nullable=true, unique=true)
  42.      */
  43.     private $username;
  44.     /**
  45.      * @var string
  46.      *
  47.      * @ORM\Column(name="password", type="string", length=255, nullable=true)
  48.      */
  49.     private $password;
  50.     /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(name="telephone1", type="string", length=100, nullable=true)
  54.      */
  55.     private $telephone1;
  56.     /**
  57.      * @var string
  58.      *
  59.      * @ORM\Column(name="telephone2", type="string", length=100, nullable=true)
  60.      */
  61.     private $telephone2;
  62.     /**
  63.      * @var string
  64.      *
  65.      * @ORM\Column(type="boolean")
  66.      */
  67.     private $is_admin;
  68.     /**
  69.      * @var boolean
  70.      *
  71.      * @ORM\Column(name="enabled", type="boolean", nullable=true)
  72.      */
  73.     private $enabled true;
  74.     /**
  75.      * @var last_login
  76.      *
  77.      * @ORM\Column(type="datetime")
  78.      */
  79.     private $last_login;
  80.     public function __toString()
  81.     {
  82.         return $this->getFirstname().' '.$this->getLastname();
  83.     }
  84.     public function getPhoto()
  85.     {
  86.         return $this->photo;
  87.     }
  88.     
  89.     public function getEmail()
  90.     {
  91.         return $this->email;
  92.     }
  93.     /**
  94.      * Get username
  95.      *
  96.      * @return string 
  97.      */
  98.     public function getUsername()
  99.     {
  100.         return $this->username;
  101.     }
  102.     /**
  103.      * Get password
  104.      *
  105.      * @return string 
  106.      */
  107.     public function getPassword(): string
  108.     {
  109.         return $this->password;
  110.     }
  111.     public function getSalt()
  112.     {
  113.         // return null beacause we are usin bcrypt
  114.         return null;
  115.     }
  116.     public function getRoles()
  117.     {
  118.         return array('ROLE_USER');
  119.     }
  120.     public function eraseCredentials()
  121.     {
  122.     }
  123.     public function isAccountNonExpired()
  124.     {
  125.         return true;
  126.     }
  127.     public function isAccountNonLocked()
  128.     {
  129.         return true;
  130.     }
  131.     public function isCredentialsNonExpired()
  132.     {
  133.         return true;
  134.     }
  135.     public function isEnabled()
  136.     {
  137.         return $this->enabled;
  138.     }
  139.     // serialize and unserialize must be updated - see below
  140.     public function serialize()
  141.     {
  142.         return serialize(array(
  143.             $this->id,
  144.             $this->username,
  145.             $this->password,
  146.             $this->enabled
  147.         ));
  148.     }
  149.     public function unserialize($serialized)
  150.     {
  151.         list (
  152.             $this->id,
  153.             $this->username,
  154.             $this->password,
  155.             $this->enabled
  156.         ) = unserialize($serialized);
  157.     }
  158.     
  159.     // super lame fix
  160.     public function getUserType()
  161.     {
  162.         return 2;
  163.     }
  164.     /**
  165.      * Set firstname
  166.      *
  167.      * @param string $firstname
  168.      * @return User
  169.      */
  170.     public function setFirstname($firstname)
  171.     {
  172.         $this->firstname $firstname;
  173.         return $this;
  174.     }
  175.     /**
  176.      * Get firstname
  177.      *
  178.      * @return string 
  179.      */
  180.     public function getFirstname()
  181.     {
  182.         return $this->firstname;
  183.     }
  184.     /**
  185.      * Set lastname
  186.      *
  187.      * @param string $lastname
  188.      * @return User
  189.      */
  190.     public function setLastname($lastname)
  191.     {
  192.         $this->lastname $lastname;
  193.         return $this;
  194.     }
  195.     /**
  196.      * Get lastname
  197.      *
  198.      * @return string 
  199.      */
  200.     public function getLastname()
  201.     {
  202.         return $this->lastname;
  203.     }
  204.     /**
  205.      * Set email
  206.      *
  207.      * @param string $email
  208.      * @return User
  209.      */
  210.     public function setEmail($email)
  211.     {
  212.         $this->email $email;
  213.         return $this;
  214.     }
  215.     /**
  216.      * Set username
  217.      *
  218.      * @param string $username
  219.      * @return User
  220.      */
  221.     public function setUsername($username)
  222.     {
  223.         $this->username $username;
  224.         return $this;
  225.     }
  226.     /**
  227.      * Set password
  228.      *
  229.      * @param string $password
  230.      * @return User
  231.      */
  232.     public function setPassword($password)
  233.     {
  234.         $this->password $password;
  235.         return $this;
  236.     }
  237.     /**
  238.      * Set enabled
  239.      *
  240.      * @param boolean $enabled
  241.      * @return User
  242.      */
  243.     public function setEnabled($enabled)
  244.     {
  245.         $this->enabled $enabled;
  246.         return $this;
  247.     }
  248.     /**
  249.      * Get enabled
  250.      *
  251.      * @return boolean 
  252.      */
  253.     public function getEnabled()
  254.     {
  255.         return $this->enabled;
  256.     }
  257.     /**
  258.      * Get id
  259.      *
  260.      * @return integer 
  261.      */
  262.     public function getId()
  263.     {
  264.         return $this->id;
  265.     }
  266.     /**
  267.      * Set is_admin
  268.      *
  269.      * @param string $isAdmin
  270.      * @return User
  271.      */
  272.     public function setIsAdmin($isAdmin)
  273.     {
  274.         $this->is_admin $isAdmin;
  275.         return $this;
  276.     }
  277.     /**
  278.      * Get is_admin
  279.      *
  280.      * @return string 
  281.      */
  282.     public function getIsAdmin()
  283.     {
  284.         return $this->is_admin;
  285.     }
  286.     /**
  287.      * Set photo
  288.      *
  289.      * @param string $photo
  290.      * @return User
  291.      */
  292.     public function setPhoto($photo)
  293.     {
  294.         $this->photo $photo;
  295.         return $this;
  296.     }
  297.     /**
  298.      * Set telephone1
  299.      *
  300.      * @param string $telephone1
  301.      * @return User
  302.      */
  303.     public function setTelephone1($telephone1)
  304.     {
  305.         $this->telephone1 $telephone1;
  306.         return $this;
  307.     }
  308.     /**
  309.      * Get telephone1
  310.      *
  311.      * @return string 
  312.      */
  313.     public function getTelephone1()
  314.     {
  315.         return $this->telephone1;
  316.     }
  317.     /**
  318.      * Set telephone2
  319.      *
  320.      * @param string $telephone2
  321.      * @return User
  322.      */
  323.     public function setTelephone2($telephone2)
  324.     {
  325.         $this->telephone2 $telephone2;
  326.         return $this;
  327.     }
  328.     /**
  329.      * Get telephone2
  330.      *
  331.      * @return string 
  332.      */
  333.     public function getTelephone2()
  334.     {
  335.         return $this->telephone2;
  336.     }
  337.     /**
  338.      * Set last_login
  339.      *
  340.      * @param datetime $last_login
  341.      * @return User
  342.      */
  343.     public function setLastLogin($last_login)
  344.     {
  345.         $this->last_login $last_login;
  346.         return $this;
  347.     }
  348.     /**
  349.      * Get last_login
  350.      *
  351.      * @return datetime 
  352.      */
  353.     public function getLastLogin()
  354.     {
  355.         return $this->last_login;
  356.     }
  357.     /**
  358.      * Constructor
  359.      */
  360.     public function __construct()
  361.     {
  362.     }
  363. }