src/Entity/Usuari.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UsuariRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. //use phpDocumentor\Reflection\Types\Boolean;
  6. use phpDocumentor\Reflection\Types\Integer;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * Usuari
  12.  */
  13.  #[ORM\Table("Usuari")]
  14.  #[ORM\Entity(repositoryClass:"App\Repository\UsuariRepository")]
  15. class Usuari implements UserInterfacePasswordAuthenticatedUserInterface\Serializable
  16. {
  17.     /**
  18.      * @var integer
  19.      */
  20.      #[ORM\Column(name:"id"type:"integer")]
  21.      #[ORM\Id]
  22.      #[ORM\GeneratedValue(strategy:"AUTO")]
  23.     private $id;
  24.     /**
  25.      * @var string
  26.      */ 
  27.      #[ORM\Column(name:"nom"type:"string"length:255nullable:true)]
  28.     private $nom;
  29.     /**
  30.      * @var boolean
  31.      */
  32.      #[ORM\Column(name:"superadmin"type:"boolean")]
  33.     private $superadmin;
  34.     /**
  35.      * @var ?string
  36.      */
  37.      #[Assert\Length(min 6)]
  38.      #[ORM\Column(name:"password"type:"string"length:255)]
  39.     private ?string $password;
  40.     /**
  41.      * @var string
  42.      */
  43.      #[Assert\NotBlank()]
  44.      #[Assert\Email()]
  45.      #[ORM\Column(name:"email"type:"string"length:255unique:true)]
  46.     private $email;
  47.     /**
  48.      * @var string
  49.      */
  50.      #[ORM\Column(name:"salt"type:"string"length:255)]
  51.     private $salt;
  52.     /**
  53.      * @var \DateTime
  54.      */
  55.      #[ORM\Column(name:"data_alta"type:"datetime")]
  56.     private $dataAlta;
  57.     /**
  58.      * @var boolean
  59.      */
  60.      #[ORM\Column(name:"activat"type:"boolean"nullable:true)]
  61.      protected $activat;
  62.     
  63.     #[ORM\ManyToOne(targetEntity:"App\Entity\Idioma")]
  64.     private $idioma;
  65.     
  66.      #[ORM\ManyToOne(targetEntity:"App\Entity\Perfils")]
  67.      #[ORM\JoinColumn(name:"perfils_id"referencedColumnName:"per_id")]
  68.     private $perfils;
  69.      #[ORM\Column(name:"direccio"type:"string"length:255nullable:true)]
  70.     protected $direccio;
  71.     
  72.      #[ORM\Column(name:"cp"type:"string"length:10nullable:true)]
  73.     protected $cp;
  74.     
  75.      #[ORM\Column(name:"poblacio"type:"string"length:255nullable:true)]
  76.     protected $poblacio;
  77.     
  78.      #[ORM\Column(name:"telefon"type:"string"length:15nullable:true)]
  79.     protected $telefon;
  80.     
  81.     /**
  82.      * @var string
  83.      */
  84.      #[ORM\Column(name:"responsable"type:"string"length:255nullable:true)]
  85.     private $responsable;
  86.     
  87.     /**
  88.      * @var string
  89.      */
  90.      #[ORM\Column(name:"codi"type:"string"length:255nullable:true)]
  91.     private $codi;
  92.     
  93.     /**
  94.      * @var boolean
  95.      */
  96.      #[ORM\Column(name:"club_esqui"type:"boolean")]
  97.     private $clubEsqui;
  98.      #[ORM\Column(name:"cada_quants_gratuit"type:"integer"nullable:true)]
  99.     protected $cadaQuantsGratuit;
  100.      #[ORM\Column(name:"quants_gratuit_fets"type:"integer"nullable:true)]
  101.     protected $quantsGratuitFets;
  102.      #[ORM\Column(name:"cada_quants_gratuit_alp"type:"integer"nullable:true)]
  103.     protected $cadaQuantsGratuitAlp;
  104.      #[ORM\Column(name:"quants_gratuit_fets_alp"type:"integer"nullable:true)]
  105.     protected $quantsGratuitFetsAlp;
  106.      /**
  107.       * @var boolean
  108.       */
  109.      #[ORM\Column(name:"clubs1"type:"boolean"nullable:true)]
  110.      private $clubs1;
  111.      /**
  112.       * @var boolean
  113.       */
  114.      #[ORM\Column(name:"clubs2"type:"boolean"nullable:true)]
  115.      private $clubs2;
  116.      /**
  117.       * @var boolean
  118.       */
  119.      #[ORM\Column(name:"clubs3"type:"boolean"nullable:true)]
  120.      private $clubs3;
  121.      /**
  122.       * @var boolean
  123.       */
  124.      #[ORM\Column(name:"clubs4"type:"boolean"nullable:true)]
  125.      private $clubs4;
  126.      /**
  127.       * @var boolean
  128.       */
  129.      #[ORM\Column(name:"lloc_central"type:"boolean"nullable:true)]
  130.      private $llocCentral;
  131.      /**
  132.       * @var boolean
  133.       */
  134.      #[ORM\Column(name:"lloc_fira"type:"boolean"nullable:true)]
  135.      private $llocFira;
  136.      /**
  137.       * @var boolean
  138.       */
  139.      #[ORM\Column(name:"lloc_oficina"type:"boolean"nullable:true)]
  140.      private $llocOficina;
  141.      /**
  142.       * @var boolean
  143.       */
  144.      #[ORM\Column(name:"lloc_clubs"type:"boolean"nullable:true)]
  145.      private $llocClubs;
  146.      /**
  147.       * @var boolean
  148.       */
  149.      #[ORM\Column(name:"lloc_web"type:"boolean"nullable:true)]
  150.      private $llocWeb;
  151.      public function __construct()
  152.     {
  153.         $this->dataAlta = new \DateTime();
  154.         $this->superadmin false;
  155.         $this->clubs1 false;
  156.         $this->clubs2 false;
  157.         $this->clubs3 false;
  158.         $this->clubs4 false;
  159.         $this->llocCentral false;
  160.         $this->llocFira false;
  161.         $this->llocOficina false;
  162.         $this->llocClubs false;
  163.         $this->llocWeb false;
  164.     }
  165.     public function __sleep()
  166.     {
  167.         return array('id''email');
  168.     }
  169.     /**
  170.      * Get id
  171.      *
  172.      * @return integer
  173.      */
  174.     public function getId(): int
  175.     {
  176.         return $this->id;
  177.     }
  178.     /**
  179.      * Set nom
  180.      *
  181.      * @param string $nom
  182.      * @return Usuari
  183.      */
  184.     public function setNom(string $nom): self
  185.     {
  186.         $this->nom $nom;
  187.         return $this;
  188.     }
  189.     /**
  190.      * Get nom
  191.      *
  192.      * @return string
  193.      */
  194.     public function getNom(): string
  195.     {
  196.         return $this->nom;
  197.     }
  198.      /**
  199.       * Set password
  200.       *
  201.       * @param string|null $password
  202.       * @return Usuari
  203.       */
  204.     public function setPassword(?   string $password): self
  205.     {
  206.         $this->password $password;
  207.         return $this;
  208.     }
  209.      /**
  210.       * Get password
  211.       *
  212.       * @return string|null
  213.       * @see PasswordAuthenticatedUserInterface
  214.       *
  215.       */
  216.     public function getPassword(): ?string
  217.     {
  218.         return $this->password;
  219.     }
  220.     /**
  221.      * Set email
  222.      *
  223.      * @param string $email
  224.      * @return Usuari
  225.      */
  226.     public function setEmail(string $email): self
  227.     {
  228.         $this->email $email;
  229.         return $this;
  230.     }
  231.     /**
  232.      * Get email
  233.      *
  234.      * @return string
  235.      */
  236.     public function getEmail(): string
  237.     {
  238.         return $this->email;
  239.     }
  240.     /**
  241.      * Set superadmin
  242.      *
  243.      * @param boolean $superadmin
  244.      * @return Usuari
  245.      */
  246.     public function setSuperadmin($superadmin): self
  247.     {
  248.         $this->superadmin $superadmin;
  249.         return $this;
  250.     }
  251.     /**
  252.      * Get superadmin
  253.      *
  254.      * @return boolean
  255.      */
  256.     public function getSuperadmin()
  257.     {
  258.         return $this->superadmin;
  259.     }
  260.     /**
  261.      * Set salt
  262.      *
  263.      * @param string $salt
  264.      * @return Usuari
  265.      */
  266.     public function setSalt(string $salt): self
  267.     {
  268.         $this->salt $salt;
  269.         return $this;
  270.     }
  271.     /**
  272.      * Get salt
  273.      * @see UserInterface
  274.      *
  275.      * @return string
  276.      */
  277.     public function getSalt(): ?string
  278.     {
  279.         return $this->salt;
  280.     }
  281.     /**
  282.      * Set dataAlta
  283.      *
  284.      * @param \DateTime $dataAlta
  285.      * @return Usuari
  286.      */
  287.     public function setDataAlta(\DateTime $dataAlta): self
  288.     {
  289.         $this->dataAlta $dataAlta;
  290.         return $this;
  291.     }
  292.     /**
  293.      * Get dataAlta
  294.      *
  295.      * @return \DateTime
  296.      */
  297.     public function getDataAlta()
  298.     {
  299.         return $this->dataAlta;
  300.     }
  301.     public function __toString()
  302.     {
  303.         return $this->getNom();
  304.     }
  305.     /**
  306.      * Set activat
  307.      *
  308.      * @param boolean $activat
  309.      * @return Usuari
  310.      */
  311.     public function setActivat($activat)
  312.     {
  313.         $this->activat $activat;
  314.         return $this;
  315.     }
  316.     /**
  317.      * Get activat
  318.      *
  319.      * @return boolean
  320.      */
  321.     public function getActivat()
  322.     {
  323.         return $this->activat;
  324.     }
  325.     function getUsername() : string
  326.     {
  327.         return $this->getEmail();
  328.     }
  329.     /**
  330.      * @see UserInterface
  331.      */
  332.     public function getRoles(): array
  333.     {
  334.         if ($this->superadmin) {
  335.             return array('ROLE_SUPER_ADMIN');
  336.         } elseif ($this->email != '') {
  337.             return array('ROLE_ADMIN');
  338.         } else {
  339.             return array('ROLE_USER');
  340.         }
  341.     }
  342.     public function setRoles(array $roles): self
  343.     {
  344.         $this->roles $roles;
  345.         return $this;
  346.     }
  347.     /**
  348.      * @see UserInterface
  349.      */
  350.     public function eraseCredentials()
  351.     {
  352.         
  353.     }
  354.     /**
  355.      * @see \Serializable::serialize()
  356.      */
  357.     public function serialize()
  358.     {
  359.         return serialize(array(
  360.             $this->id,
  361.             $this->email,
  362.             $this->password,
  363.                 // see section on salt below
  364.                 // $this->salt,
  365.         ));
  366.     }
  367.     /**
  368.      * @see \Serializable::unserialize()
  369.      */
  370.     public function unserialize($serialized)
  371.     {
  372.         list (
  373.                 $this->id,
  374.                 $this->email,
  375.                 $this->password,
  376.                 // see section on salt below
  377.                 // $this->salt
  378.                 ) = unserialize($serialized);
  379.     }
  380.     public function isAccountNonExpired()
  381.     {
  382.         return true;
  383.     }
  384.     public function isAccountNonLocked()
  385.     {
  386.         return true;
  387.     }
  388.     public function isCredentialsNonExpired()
  389.     {
  390.         return true;
  391.     }
  392.     
  393.     public function isEnabled()
  394.     {
  395.         return $this->getActivat();
  396.     }
  397.     /**
  398.      * Set Idioma
  399.      *
  400.      * @param \App\Entity\Idioma $idioma
  401.      * @return Usuari
  402.      */
  403.     public function setIdioma(\App\Entity\Idioma $idioma): self
  404.     {
  405.         $this->idioma $idioma;
  406.         return $this;
  407.     }
  408.     /**
  409.      * Get idioma
  410.      *
  411.      * @return string
  412.      */
  413.     public function getIdioma()
  414.     {
  415.         return $this->idioma;
  416.     }    
  417.     
  418.     /**
  419.      * Set Perfils
  420.      *
  421.      * @param \App\Entity\Perfils $perfils
  422.      * @return Usuari
  423.      */
  424.     public function setPerfils(\App\Entity\Perfils $perfils)
  425.     {
  426.         $this->perfils $perfils;
  427.         return $this;
  428.     }
  429.     /**
  430.      * Get perfils
  431.      *
  432.      * @return string
  433.      */
  434.     public function getPerfils()
  435.     {
  436.         return $this->perfils;
  437.     }    
  438.     
  439.     /**
  440.      * Set direccio
  441.      *
  442.      * @param string $direccio
  443.      * @return Usuari
  444.      */
  445.     public function setDireccio(string $direccio): self
  446.     {
  447.         $this->direccio $direccio;
  448.         return $this;
  449.     }
  450.     /**
  451.      * Get direccio
  452.      *
  453.      * @return string 
  454.      */
  455.     public function getDireccio()
  456.     {
  457.         return $this->direccio;
  458.     }
  459.     /**
  460.      * Set cp
  461.      *
  462.      * @param string $cp
  463.      * @return Usuari
  464.      */
  465.     public function setCp(string $cp): self
  466.     {
  467.         $this->cp $cp;
  468.         return $this;
  469.     }
  470.     /**
  471.      * Get cp
  472.      *
  473.      * @return string 
  474.      */
  475.     public function getCp()
  476.     {
  477.         return $this->cp;
  478.     }
  479.     /**
  480.      * Set poblacio
  481.      *
  482.      * @param string $poblacio
  483.      * @return Usuari
  484.      */
  485.     public function setPoblacio(string $poblacio): self
  486.     {
  487.         $this->poblacio $poblacio;
  488.         return $this;
  489.     }
  490.     /**
  491.      * Get poblacio
  492.      *
  493.      * @return string 
  494.      */
  495.     public function getPoblacio()
  496.     {
  497.         return $this->poblacio;
  498.     }
  499.     /**
  500.      * Set telefon
  501.      *
  502.      * @param string $telefon
  503.      * @return Usuari
  504.      */
  505.     public function setTelefon(string $telefon): self
  506.     {
  507.         $this->telefon $telefon;
  508.         return $this;
  509.     }
  510.     /**
  511.      * Get telefon
  512.      *
  513.      * @return string 
  514.      */
  515.     public function getTelefon()
  516.     {
  517.         return $this->telefon;
  518.     }
  519.     /**
  520.      * Set responsable
  521.      *
  522.      * @param string $responsable
  523.      * @return Usuari
  524.      */
  525.     public function setResponsable(string $responsable): self
  526.     {
  527.         $this->responsable $responsable;
  528.         return $this;
  529.     }
  530.     /**
  531.      * Get responsable
  532.      *
  533.      * @return string 
  534.      */
  535.     public function getResponsable()
  536.     {
  537.         return $this->responsable;
  538.     }
  539.     /**
  540.      * Set codi
  541.      *
  542.      * @param string $codi
  543.      * @return Usuari
  544.      */
  545.     public function setCodi(string $codi): self
  546.     {
  547.         $this->codi $codi;
  548.         return $this;
  549.     }
  550.     /**
  551.      * Get codi
  552.      *
  553.      * @return string 
  554.      */
  555.     public function getCodi()
  556.     {
  557.         return $this->codi;
  558.     }
  559.     /**
  560.      * Set clubEsqui
  561.      *
  562.      * @param boolean $clubEsqui
  563.      * @return Usuari
  564.      */
  565.     public function setClubEsqui($clubEsqui)
  566.     {
  567.         $this->clubEsqui $clubEsqui;
  568.         return $this;
  569.     }
  570.     /**
  571.      * Get clubEsqui
  572.      *
  573.      * @return boolean 
  574.      */
  575.     public function getClubEsqui()
  576.     {
  577.         return $this->clubEsqui;
  578.     }
  579.     /**
  580.      * Set cadaQuantsGratuit
  581.      *
  582.      * @param integer $cadaQuantsGratuit
  583.      * @return Usuari
  584.      */
  585.     public function setCadaQuantsGratuit($cadaQuantsGratuit): self
  586.     {
  587.         $this->cadaQuantsGratuit $cadaQuantsGratuit;
  588.         return $this;
  589.     }
  590.     /**
  591.      * Get cadaQuantsGratuit
  592.      *
  593.      * @return integer 
  594.      */
  595.     public function getCadaQuantsGratuit()
  596.     {
  597.         return $this->cadaQuantsGratuit;
  598.     }
  599.     /**
  600.      * Set quantsGratuitFets
  601.      *
  602.      * @param integer $quantsGratuitFets
  603.      * @return Usuari
  604.      */
  605.     public function setQuantsGratuitFets($quantsGratuitFets): self
  606.     {
  607.         $this->quantsGratuitFets $quantsGratuitFets;
  608.         return $this;
  609.     }
  610.     /**
  611.      * Get quantsGratuitFets
  612.      *
  613.      * @return integer 
  614.      */
  615.     public function getQuantsGratuitFets()
  616.     {
  617.         return $this->quantsGratuitFets;
  618.     }
  619.     /**
  620.      * Set cadaQuantsGratuitAlp
  621.      *
  622.      * @param integer $cadaQuantsGratuitAlp
  623.      * @return Usuari
  624.      */
  625.     public function setCadaQuantsGratuitAlp($cadaQuantsGratuitAlp): self
  626.     {
  627.         $this->cadaQuantsGratuitAlp $cadaQuantsGratuitAlp;
  628.         return $this;
  629.     }
  630.     /**
  631.      * Get cadaQuantsGratuitAlp
  632.      *
  633.      * @return integer 
  634.      */
  635.     public function getCadaQuantsGratuitAlp()
  636.     {
  637.         return $this->cadaQuantsGratuitAlp;
  638.     }
  639.     /**
  640.      * Set quantsGratuitFetsAlp
  641.      *
  642.      * @param integer $quantsGratuitFetsAlp
  643.      * @return Usuari
  644.      */
  645.     public function setQuantsGratuitFetsAlp($quantsGratuitFetsAlp): self
  646.     {
  647.         $this->quantsGratuitFetsAlp $quantsGratuitFetsAlp;
  648.         return $this;
  649.     }
  650.     /**
  651.      * Get quantsGratuitFetsAlp
  652.      *
  653.      * @return integer 
  654.      */
  655.     public function getQuantsGratuitFetsAlp()
  656.     {
  657.         return $this->quantsGratuitFetsAlp;
  658.     }
  659.     /**
  660.      * The public representation of the user (e.g. a username, an email address, etc.)
  661.      *
  662.      * @see UserInterface
  663.      */
  664.     public function getUserIdentifier(): string
  665.     {
  666.         return (string) $this->email;
  667.     }
  668.      /**
  669.       * Set clubs1
  670.       *
  671.       * @param boolean $clubs1
  672.       * @return Usuari
  673.       */
  674.      public function setClubs1($clubs1): self
  675.      {
  676.          $this->clubs1 $clubs1;
  677.          return $this;
  678.      }
  679.      /**
  680.       * Get clubs1
  681.       *
  682.       * @return boolean
  683.       */
  684.      public function getClubs1()
  685.      {
  686.          return $this->clubs1;
  687.      }
  688.      /**
  689.       * Set clubs2
  690.       *
  691.       * @param boolean $clubs2
  692.       * @return Usuari
  693.       */
  694.      public function setClubs2($clubs2): self
  695.      {
  696.          $this->clubs2 $clubs2;
  697.          return $this;
  698.      }
  699.      /**
  700.       * Get clubs2
  701.       *
  702.       * @return boolean
  703.       */
  704.      public function getClubs2()
  705.      {
  706.          return $this->clubs2;
  707.      }
  708.      /**
  709.       * Set clubs3
  710.       *
  711.       * @param boolean $clubs3
  712.       * @return Usuari
  713.       */
  714.      public function setClubs3($clubs3): self
  715.      {
  716.          $this->clubs3 $clubs3;
  717.          return $this;
  718.      }
  719.      /**
  720.       * Get clubs3
  721.       *
  722.       * @return boolean
  723.       */
  724.      public function getClubs3()
  725.      {
  726.          return $this->clubs3;
  727.      }
  728.      /**
  729.       * Set clubs4
  730.       *
  731.       * @param boolean $clubs4
  732.       * @return Usuari
  733.       */
  734.      public function setClubs4($clubs4): self
  735.      {
  736.          $this->clubs4 $clubs4;
  737.          return $this;
  738.      }
  739.      /**
  740.       * Get clubs4
  741.       *
  742.       * @return boolean
  743.       */
  744.      public function getClubs4()
  745.      {
  746.          return $this->clubs4;
  747.      }
  748.      /**
  749.       * Set llocCentral
  750.       *
  751.       * @param boolean $llocCentral
  752.       * @return Usuari
  753.       */
  754.      public function setLlocCentral($llocCentral): self
  755.      {
  756.          $this->llocCentral $llocCentral;
  757.          return $this;
  758.      }
  759.      /**
  760.       * Get llocCentral
  761.       *
  762.       * @return boolean
  763.       */
  764.      public function getLlocCentral()
  765.      {
  766.          return $this->llocCentral;
  767.      }
  768.      /**
  769.       * Set llocFira
  770.       *
  771.       * @param boolean $llocFira
  772.       * @return Usuari
  773.       */
  774.      public function setLlocFira($llocFira): self
  775.      {
  776.          $this->llocFira $llocFira;
  777.          return $this;
  778.      }
  779.      /**
  780.       * Get llocFira
  781.       *
  782.       * @return boolean
  783.       */
  784.      public function getLlocFira()
  785.      {
  786.          return $this->llocFira;
  787.      }
  788.      /**
  789.       * Set llocOficina
  790.       *
  791.       * @param boolean $llocOficina
  792.       * @return Usuari
  793.       */
  794.      public function setLlocOficina($llocOficina): self
  795.      {
  796.          $this->llocOficina $llocOficina;
  797.          return $this;
  798.      }
  799.      /**
  800.       * Get llocOficina
  801.       *
  802.       * @return boolean
  803.       */
  804.      public function getLlocOficina()
  805.      {
  806.          return $this->llocOficina;
  807.      }
  808.      /**
  809.       * Set llocClubs
  810.       *
  811.       * @param boolean $llocClubs
  812.       * @return Usuari
  813.       */
  814.      public function setLlocClubs($llocClubs): self
  815.      {
  816.          $this->llocClubs $llocClubs;
  817.          return $this;
  818.      }
  819.      /**
  820.       * Get llocClubs
  821.       *
  822.       * @return boolean
  823.       */
  824.      public function getLlocClubs()
  825.      {
  826.          return $this->llocClubs;
  827.      }
  828.      /**
  829.       * Set llocWeb
  830.       *
  831.       * @param boolean $llocWeb
  832.       * @return Usuari
  833.       */
  834.      public function setLlocWeb($llocWeb): self
  835.      {
  836.          $this->llocWeb $llocWeb;
  837.          return $this;
  838.      }
  839.      /**
  840.       * Get llocWeb
  841.       *
  842.       * @return boolean
  843.       */
  844.      public function getLlocWeb()
  845.      {
  846.          return $this->llocWeb;
  847.      }
  848.  }