src/Entity/User.php line 29

Open in your IDE?
  1. <?php
  2. /**
  3.  * Created by Mediterranean Develup Solutions.
  4.  * User: jorge.defreitas@develup.solutions
  5.  * Date: 14/06/2017
  6.  * Time: 16:51
  7.  */
  8. namespace App\Entity;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Security\Core\User\UserInterface;
  13. use Symfony\Component\Serializer\Annotation\Groups;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  16. /**
  17.  * User
  18.  *
  19.  * @ORM\Table(name="users")
  20.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  21.  * @UniqueEntity("username")
  22.  * @UniqueEntity("email")
  23.  * @ORM\HasLifecycleCallbacks()
  24.  */
  25. class User implements UserInterface{
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue(strategy="AUTO")
  29.      * @ORM\Column(type="integer")
  30.      * 
  31.      * @Groups({"assistant:read"})
  32.      */
  33.     private $id;
  34.     /**
  35.      * @ORM\Column(name="picture", type="string", length=255, nullable=true)
  36.      *
  37.      */
  38.     private $picture;
  39.     /**
  40.      * @ORM\Column(name="username", type="string", length=255, unique=true)
  41.      * @Assert\NotBlank()
  42.      * 
  43.      * @Groups({"assistant:read"})
  44.      */
  45.     private $username;
  46.     /**
  47.      * @ORM\Column(name="email", type="string", length=255, unique=true)
  48.      * @Assert\NotBlank()
  49.      * @Assert\Email()
  50.      * 
  51.      * @Groups({"assistant:read"})
  52.      */
  53.     private $email;
  54.     /**
  55.      * @ORM\Column(name="password", type="string", length=64)
  56.      */
  57.     private $password;
  58.     /**
  59.      * @ORM\Column(name="movil_password", type="string", length=255, nullable=true)
  60.      */
  61.     private $movilPassword;
  62.     /**
  63.      * @ORM\Column(name="pass_gmail", type="string", length=100, nullable=true)
  64.      */
  65.     private $passGmail;
  66.     /**
  67.      * @ORM\Column(name="firm_gmail", type="text", nullable=true)
  68.      */
  69.     private $firmGmail;
  70.     /**
  71.      * @ORM\Column(name="name", type="string", length=255)
  72.      * @Assert\NotBlank()
  73.      * 
  74.      * @Groups({"assistant:read"})
  75.      */
  76.     private $name;
  77.     /**
  78.      * @ORM\Column(name="last_name", type="string", length=255)
  79.      * @Assert\NotBlank()
  80.      * 
  81.      * @Groups({"assistant:read"})
  82.      */
  83.     private $lastname;
  84.     /**
  85.      * @ORM\Column(name="telephone", type="string", length=255, nullable=true)
  86.      */
  87.     private $telephone;
  88.     /**
  89.      * @ORM\Column(name="mobile", type="string", length=255, nullable=true)
  90.      */
  91.     private $mobile;
  92.     /**
  93.      * @ORM\Column(name="id_office", type="integer", length=11, nullable=true)
  94.      */
  95.     private $office;
  96.     /**
  97.      * @ORM\Column(name="status", type="boolean")
  98.      */
  99.     private $status;
  100.     /**
  101.      * @ORM\Column(name="id_company", type="integer", length=11, nullable=true)
  102.      */
  103.     private $company;
  104.     /**
  105.      * @ORM\Column(name="id_user_rol", type="integer", length=11, nullable=true)
  106.      * 
  107.      */
  108.     private $userrol;
  109.     /**
  110.      * @ORM\Column(name="id_team", type="integer", length=11, nullable=true)
  111.      */
  112.     private $team;
  113.     /**
  114.      * @ORM\Column(name="team_leader", type="boolean", nullable=true)
  115.      */
  116.     private $teamleader;
  117.     /**
  118.      * @ORM\Column(name="role", type="string", length=50)
  119.      */
  120.     private $role;
  121.     /**
  122.      * @ORM\Column(type="string", length=255, nullable=true)
  123.      */
  124.     private $accessKey;
  125.     /**
  126.      * @var string
  127.      * @ORM\Column(name="language", type="string", length=11, nullable=true)
  128.      */
  129.     private $language;
  130.     /**
  131.      * @var string
  132.      * @ORM\Column(name="color", type="string", length=11, nullable=true)
  133.      */
  134.     private $color;
  135.     /**
  136.      * @ORM\Column(name="sidebar", type="boolean", nullable=true)
  137.      */
  138.     private $sidebar;
  139.     /**
  140.      * @var \Datetime
  141.      *
  142.      * @ORM\Column(name="created_at", type="datetime")
  143.      */
  144.     private $createdAt;
  145.     /**
  146.      * @var \Datetime
  147.      *
  148.      * @ORM\Column(name="updated_at", type="datetime")
  149.      */
  150.     private $updatedAt;
  151.     /**
  152.      * @ORM\Column(name="description", type="text", nullable=true)
  153.      */
  154.     private $description;
  155.     /**
  156.      * @var string
  157.      * @ORM\Column(name="job_title", type="string", length=255, nullable=true)
  158.      */
  159.     private $jobTitle;
  160.     /**
  161.      * @ORM\OneToMany(targetEntity=UserNotification::class, mappedBy="user", orphanRemoval=true)
  162.      */
  163.     private $userNotifications;
  164.     public function __construct()
  165.     {
  166.         $this->userNotifications = new ArrayCollection();
  167.     }
  168.     public function getId()
  169.     {
  170.         return $this->id;
  171.     }
  172.     public function setId($id)
  173.     {
  174.         $this->id $id;
  175.     }
  176.     public function getEmail()
  177.     {
  178.         return $this->email;
  179.     }
  180.     public function setEmail($email)
  181.     {
  182.         $this->email $email;
  183.     }
  184.     public function getUsername()
  185.     {
  186.         return $this->username;
  187.     }
  188.     public function setUsername($username)
  189.     {
  190.         $this->username $username;
  191.     }
  192.     public function getPassword()
  193.     {
  194.         return $this->password;
  195.     }
  196.     public function setPassword($password)
  197.     {
  198.         $this->password $password;
  199.     }
  200.     public function getSalt()
  201.     {
  202.         // The bcrypt algorithm doesn't require a separate salt.
  203.         // You *may* need a real salt if you choose a different encoder.
  204.         //return null;
  205.     }
  206.     public function eraseCredentials()
  207.     {
  208.     }
  209.     public function getRole()
  210.     {
  211.         return $this->role;
  212.     }
  213.     public function setRole($role null)
  214.     {
  215.         $this->role $role;
  216.     }
  217.     public function getRoles()
  218.     {
  219.         return [$this->getRole()];
  220.     }
  221.     public function getAccessKey()
  222.     {
  223.         return $this->accessKey;
  224.     }
  225.     public function setAccessKey($accessKey null)
  226.     {
  227.         $this->accessKey $accessKey;
  228.     }
  229.     /**
  230.      * Set createdAt
  231.      *
  232.      * @param \Datetime $createdAt
  233.      *
  234.      * @return User
  235.      */
  236.     public function setCreatedAt(\Datetime $createdAt)
  237.     {
  238.         $this->createdAt $createdAt;
  239.         return $this;
  240.     }
  241.     /**
  242.      * Get createdAt
  243.      *
  244.      * @return \Datetime
  245.      */
  246.     public function getCreatedAt()
  247.     {
  248.         return $this->createdAt;
  249.     }
  250.     /**
  251.      * Set updatedAt
  252.      *
  253.      * @param \Datetime $updatedAt
  254.      *
  255.      * @return User
  256.      */
  257.     public function setUpdatedAt(\Datetime $updatedAt)
  258.     {
  259.         $this->updatedAt $updatedAt;
  260.         return $this;
  261.     }
  262.     /**
  263.      * Get updatedAt
  264.      *
  265.      * @return \Datetime
  266.      */
  267.     public function getUpdatedAt()
  268.     {
  269.         return $this->updatedAt;
  270.     }
  271.     /**
  272.      * @ORM\PrePersist
  273.      */
  274.     public function setCreatedAtValue()
  275.     {
  276.         $this->createdAt = new \Datetime();
  277.     }
  278.     /**
  279.      * @ORM\PrePersist
  280.      * @ORM\PreUpdate
  281.      */
  282.     public function setUpdatedAtValue()
  283.     {
  284.         $this->updatedAt = new \Datetime();
  285.     }
  286.     /**
  287.      * Set picture
  288.      *
  289.      * @param string $picture
  290.      *
  291.      * @return User
  292.      */
  293.     public function setPicture($picture)
  294.     {
  295.         $this->picture $picture;
  296.         return $this;
  297.     }
  298.     /**
  299.      * Get picture
  300.      *
  301.      * @return string
  302.      */
  303.     public function getPicture()
  304.     {
  305.         return $this->picture;
  306.     }
  307.     /**
  308.      * Set name
  309.      *
  310.      * @param string $name
  311.      *
  312.      * @return User
  313.      */
  314.     public function setName($name)
  315.     {
  316.         $this->name $name;
  317.         return $this;
  318.     }
  319.     /**
  320.      * Get name
  321.      *
  322.      * @return string
  323.      */
  324.     public function getName()
  325.     {
  326.         return $this->name;
  327.     }
  328.     /**
  329.      * Set lastname
  330.      *
  331.      * @param string $lastname
  332.      *
  333.      * @return User
  334.      */
  335.     public function setLastname($lastname)
  336.     {
  337.         $this->lastname $lastname;
  338.         return $this;
  339.     }
  340.     /**
  341.      * Get lastname
  342.      *
  343.      * @return string
  344.      */
  345.     public function getLastname()
  346.     {
  347.         return $this->lastname;
  348.     }
  349.     /**
  350.      * Set telephone
  351.      *
  352.      * @param string $telephone
  353.      *
  354.      * @return User
  355.      */
  356.     public function setTelephone($telephone)
  357.     {
  358.         $this->telephone $telephone;
  359.         return $this;
  360.     }
  361.     /**
  362.      * Get telephone
  363.      *
  364.      * @return string
  365.      */
  366.     public function getTelephone()
  367.     {
  368.         return $this->telephone;
  369.     }
  370.     /**
  371.      * Set mobile
  372.      *
  373.      * @param string $mobile
  374.      *
  375.      * @return User
  376.      */
  377.     public function setMobile($mobile)
  378.     {
  379.         $this->mobile $mobile;
  380.         return $this;
  381.     }
  382.     /**
  383.      * Get mobile
  384.      *
  385.      * @return string
  386.      */
  387.     public function getMobile()
  388.     {
  389.         return $this->mobile;
  390.     }
  391.     /**
  392.      * Set office
  393.      *
  394.      * @param integer $office
  395.      *
  396.      * @return User
  397.      */
  398.     public function setOffice($office)
  399.     {
  400.         $this->office $office;
  401.         return $this;
  402.     }
  403.     /**
  404.      * Get office
  405.      *
  406.      * @return integer
  407.      */
  408.     public function getOffice()
  409.     {
  410.         return $this->office;
  411.     }
  412.     /**
  413.      * Set status
  414.      *
  415.      * @param boolean $status
  416.      *
  417.      * @return User
  418.      */
  419.     public function setStatus($status)
  420.     {
  421.         $this->status $status;
  422.         return $this;
  423.     }
  424.     /**
  425.      * Get status
  426.      *
  427.      * @return boolean
  428.      */
  429.     public function getStatus()
  430.     {
  431.         return $this->status;
  432.     }
  433.     /**
  434.      * Set company
  435.      *
  436.      * @param integer $company
  437.      *
  438.      * @return User
  439.      */
  440.     public function setCompany($company)
  441.     {
  442.         $this->company $company;
  443.         return $this;
  444.     }
  445.     /**
  446.      * Get company
  447.      *
  448.      * @return integer
  449.      */
  450.     public function getCompany()
  451.     {
  452.         return $this->company;
  453.     }
  454.     /**
  455.      * Set userrol
  456.      *
  457.      * @param integer $userrol
  458.      *
  459.      * @return User
  460.      */
  461.     public function setUserrol($userrol)
  462.     {
  463.         $this->userrol $userrol;
  464.         return $this;
  465.     }
  466.     /**
  467.      * Get userrol
  468.      *
  469.      * @return integer
  470.      */
  471.     public function getUserrol()
  472.     {
  473.         return $this->userrol;
  474.     }
  475.     /**
  476.      * Set team
  477.      *
  478.      * @param integer $team
  479.      *
  480.      * @return User
  481.      */
  482.     public function setTeam($team)
  483.     {
  484.         $this->team $team;
  485.         return $this;
  486.     }
  487.     /**
  488.      * Get team
  489.      *
  490.      * @return integer
  491.      */
  492.     public function getTeam()
  493.     {
  494.         return $this->team;
  495.     }
  496.     /**
  497.      * Set teamleader
  498.      *
  499.      * @param boolean $teamleader
  500.      *
  501.      * @return User
  502.      */
  503.     public function setTeamleader($teamleader)
  504.     {
  505.         $this->teamleader $teamleader;
  506.         return $this;
  507.     }
  508.     /**
  509.      * Get teamleader
  510.      *
  511.      * @return boolean
  512.      */
  513.     public function getTeamleader()
  514.     {
  515.         return $this->teamleader;
  516.     }
  517.     /**
  518.      * Set language
  519.      *
  520.      * @param string $language
  521.      *
  522.      * @return User
  523.      */
  524.     public function setLanguage($language)
  525.     {
  526.         $this->language $language;
  527.         return $this;
  528.     }
  529.     /**
  530.      * Get language
  531.      *
  532.      * @return string
  533.      */
  534.     public function getLanguage()
  535.     {
  536.         return $this->language;
  537.     }
  538.     /**
  539.      * Set passGmail
  540.      *
  541.      * @param string $passGmail
  542.      *
  543.      * @return User
  544.      */
  545.     public function setPassGmail($passGmail)
  546.     {
  547.         $this->passGmail $passGmail;
  548.         return $this;
  549.     }
  550.     /**
  551.      * Get passGmail
  552.      *
  553.      * @return string
  554.      */
  555.     public function getPassGmail()
  556.     {
  557.         return $this->passGmail;
  558.     }
  559.     /**
  560.      * Set firmGmail
  561.      *
  562.      * @param string $firmGmail
  563.      *
  564.      * @return User
  565.      */
  566.     public function setFirmGmail($firmGmail)
  567.     {
  568.         $this->firmGmail $firmGmail;
  569.         return $this;
  570.     }
  571.     /**
  572.      * Get firmGmail
  573.      *
  574.      * @return string
  575.      */
  576.     public function getFirmGmail()
  577.     {
  578.         return $this->firmGmail;
  579.     }
  580.     /**
  581.      * Set color
  582.      *
  583.      * @param string $color
  584.      *
  585.      * @return User
  586.      */
  587.     public function setColor($color)
  588.     {
  589.         $this->color $color;
  590.         return $this;
  591.     }
  592.     /**
  593.      * Get color
  594.      *
  595.      * @return string
  596.      */
  597.     public function getColor()
  598.     {
  599.         return $this->color;
  600.     }
  601.     /**
  602.      * Set sidebar
  603.      *
  604.      * @param boolean $sidebar
  605.      *
  606.      * @return User
  607.      */
  608.     public function setSidebar($sidebar)
  609.     {
  610.         $this->sidebar $sidebar;
  611.         return $this;
  612.     }
  613.     /**
  614.      * Get sidebar
  615.      *
  616.      * @return boolean
  617.      */
  618.     public function getSidebar()
  619.     {
  620.         return $this->sidebar;
  621.     }
  622.     /**
  623.      * Set description
  624.      *
  625.      * @param string $description
  626.      *
  627.      * @return User
  628.      */
  629.     public function setDescription($description)
  630.     {
  631.         $this->description $description;
  632.         return $this;
  633.     }
  634.     /**
  635.      * Get description
  636.      *
  637.      * @return string
  638.      */
  639.     public function getDescription()
  640.     {
  641.         return $this->description;
  642.     }
  643.     /**
  644.      * Set jobTitle
  645.      *
  646.      * @param string $jobTitle
  647.      *
  648.      * @return User
  649.      */
  650.     public function setJobTitle($jobTitle)
  651.     {
  652.         $this->jobTitle $jobTitle;
  653.         return $this;
  654.     }
  655.     /**
  656.      * Get jobTitle
  657.      *
  658.      * @return string
  659.      */
  660.     public function getJobTitle()
  661.     {
  662.         return $this->jobTitle;
  663.     }
  664.     public function getFullName() {
  665.         return $this->name " " $this->lastname;
  666.     }
  667.     /**
  668.      * Set movilPassword
  669.      *
  670.      * @param string $movilPassword
  671.      *
  672.      * @return User
  673.      */
  674.     public function setMovilPassword($movilPassword)
  675.     {
  676.         $this->movilPassword $movilPassword;
  677.         return $this;
  678.     }
  679.     /**
  680.      * Get movilPassword
  681.      *
  682.      * @return string
  683.      */
  684.     public function getMovilPassword()
  685.     {
  686.         return $this->movilPassword;
  687.     }
  688.     /**
  689.      * @return Collection<int, UserNotification>
  690.      */
  691.     public function getUserNotifications(): Collection
  692.     {
  693.         return $this->userNotifications;
  694.     }
  695.     public function addUserNotification(UserNotification $userNotification): self
  696.     {
  697.         if (!$this->userNotifications->contains($userNotification)) {
  698.             $this->userNotifications[] = $userNotification;
  699.             $userNotification->setUser($this);
  700.         }
  701.         return $this;
  702.     }
  703.     public function removeUserNotification(UserNotification $userNotification): self
  704.     {
  705.         if ($this->userNotifications->removeElement($userNotification)) {
  706.             // set the owning side to null (unless already changed)
  707.             if ($userNotification->getUser() === $this) {
  708.                 $userNotification->setUser(null);
  709.             }
  710.         }
  711.         return $this;
  712.     }
  713. }