src/Entity/Usuario.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  5. use Symfony\Component\Security\Core\User\UserInterface;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. /**
  8.  * Usuario
  9.  *
  10.  * @ORM\Table(name="usuario", indexes={@ORM\Index(name="usuario_unidad_id_uni_fk", columns={"unidad"}), @ORM\Index(name="usuario_rol_id_rol_fk", columns={"rol"})})
  11.  * @ORM\Entity
  12.  * @method string getUserIdentifier()
  13.  * @UniqueEntity(fields={"correo"}, message="Existe un usuario registrado con el mismo correo")
  14.  */
  15. class Usuario implements UserInterface\Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface
  16. {
  17.     /**
  18.      * @var int
  19.      *
  20.      * @ORM\Column(name="id_usu", type="integer", nullable=false)
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="IDENTITY")
  23.      * @Groups({"api_read"})
  24.      */
  25.     private $idUsu;
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(name="nombre", type="string", length=50, nullable=false)
  30.      * @Groups({"api_read"})
  31.      */
  32.     private $nombre;
  33.     /**
  34.      * @var string
  35.      *
  36.      * @ORM\Column(name="papellido", type="string", length=50, nullable=false)
  37.      * @Groups({"api_read"})
  38.      */
  39.     private $papellido;
  40.     /**
  41.      * @var string|null
  42.      *
  43.      * @ORM\Column(name="sapellido", type="string", length=50, nullable=true)
  44.      * @Groups({"api_read"})
  45.      */
  46.     private $sapellido;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="correo", type="string", length=80, nullable=false)
  51.      * @Groups({"api_read"})
  52.      */
  53.     private $correo;
  54.     /**
  55.      * @var string
  56.      *
  57.      * @ORM\Column(name="contrasena", type="string", length=100, nullable=false)
  58.      */
  59.     private $contrasena;
  60.     /**
  61.      * @var \Unidad
  62.      *
  63.      * @ORM\ManyToOne(targetEntity="Unidad")
  64.      * @ORM\JoinColumns({
  65.      *   @ORM\JoinColumn(name="unidad", referencedColumnName="id_uni")
  66.      * })
  67.      * @Groups({"api_read"})
  68.      */
  69.     private $unidad;
  70.     /**
  71.      * @var \Role
  72.      *
  73.      * @ORM\ManyToOne(targetEntity="Role")
  74.      * @ORM\JoinColumns({
  75.      *   @ORM\JoinColumn(name="rol", referencedColumnName="id_rol")
  76.      * })
  77.      * @Groups({"api_read"})
  78.      */
  79.     private $rol;
  80.     /**
  81.      * @var string
  82.      *
  83.      * @ORM\Column(name="estatus", type="string", length=12, nullable=false)
  84.      * @Groups({"api_read"})
  85.      */
  86.     private $estatus;
  87.     public function getIdUsu(): ?int
  88.     {
  89.         return $this->idUsu;
  90.     }
  91.     public function getNombre(): ?string
  92.     {
  93.         return $this->nombre;
  94.     }
  95.     public function setNombre(string $nombre): self
  96.     {
  97.         $this->nombre $nombre;
  98.         return $this;
  99.     }
  100.     public function getPapellido(): ?string
  101.     {
  102.         return $this->papellido;
  103.     }
  104.     public function setPapellido(?string $papellido): self
  105.     {
  106.         $this->papellido $papellido;
  107.         return $this;
  108.     }
  109.     public function getSapellido(): ?string
  110.     {
  111.         return $this->sapellido;
  112.     }
  113.     public function setSapellido(?string $sapellido): self
  114.     {
  115.         $this->sapellido $sapellido;
  116.         return $this;
  117.     }
  118.     public function getCorreo(): ?string
  119.     {
  120.         return $this->correo;
  121.     }
  122.     public function setCorreo(string $correo): self
  123.     {
  124.         $this->correo $correo;
  125.         return $this;
  126.     }
  127.     public function getContrasena(): ?string
  128.     {
  129.         return $this->contrasena;
  130.     }
  131.     public function setContrasena(string $contrasena): self
  132.     {
  133.         $this->contrasena $contrasena;
  134.         return $this;
  135.     }
  136.     public function getUnidad(): ?Unidad
  137.     {
  138.         return $this->unidad;
  139.     }
  140.     public function setUnidad(?Unidad $unidad): self
  141.     {
  142.         $this->unidad $unidad;
  143.         return $this;
  144.     }
  145.     public function getRol(): ?Role
  146.     {
  147.         return $this->rol;
  148.     }
  149.     public function setRol(?Role $rol): self
  150.     {
  151.         $this->rol $rol;
  152.         return $this;
  153.     }
  154.     public function getRoles()
  155.     {
  156.         return ['ROLE_PLANTEL'];
  157.     }
  158.     public function getPassword(): ?string
  159.     {
  160.         return $this->getContrasena();
  161.     }
  162.     public function getSalt()
  163.     {
  164.         return null;
  165.     }
  166.     public function eraseCredentials()
  167.     {
  168.     }
  169.     public function getUsername()
  170.     {
  171.         return $this->getCorreo();
  172.     }
  173.     public function __call($name$arguments)
  174.     {
  175.     }
  176.     public function getEstatus(): string
  177.     {
  178.         return $this->estatus;
  179.     }
  180.     public function setEstatus(string $estatus): self
  181.     {
  182.         $this->estatus $estatus;
  183.         return $this;
  184.     }
  185.     
  186.     public function __toString()
  187.     {
  188.         return $this->nombre;
  189.     }
  190.     // Entidad de usuario
  191. }