Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:44:12+00:00 2026-06-16T00:44:12+00:00

This is my user entity <?php namespace Monse\UsuariosBundle\Entity; use Symfony\Component\Security\Core\User\UserInterface; use Doctrine\ORM\Mapping as ORM;

  • 0

This is my user entity

<?php

namespace Monse\UsuariosBundle\Entity;

use Symfony\Component\Security\Core\User\UserInterface;
use Doctrine\ORM\Mapping as ORM;

/**
 * Monse\UsuariosBundle\Entity\Usuario
 *
 * @ORM\Table(name="users")
 * @ORM\Entity
 */
class Usuario implements UserInterface
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /** 
 * @ORM\OneToOne(targetEntity="Monse\ClientesBundle\Entity\Cliente")
 * @ORM\JoinColumn(name="cliente_id", referencedColumnName="id",nullable=true)
*/
    protected $cliente;

    /**
     * @var string $usuario
     *
     * @ORM\Column(name="usuario", type="string", length=255, unique=true)
     */
    protected $usuario;

    /**
     * @var string $email
     *
     * @ORM\Column(name="email", type="string", length=255, unique=true)
     */
    protected $email;

    /**
     * @var string $password
     *
     * @ORM\Column(name="password", type="string", length=255)
     */
    protected $password;

    /**
     * @var string $salt
     *
     * @ORM\Column(name="salt", type="string", length=255)
     */
    protected $salt;

    /**
     * @var date $ultimo_ingreso
     *
     * @ORM\Column(name="ultimo_ingreso", type="date")
     */
    protected $ultimo_ingreso;

    /**
     * @var date $fecha_alta
     *
     * @ORM\Column(name="fecha_alta", type="date")
     */
    protected $fecha_alta;

     /**
* @ORM\ManyToOne(targetEntity="Monse\UsuariosBundle\Entity\Rol")
* @ORM\JoinColumn(name="rol", referencedColumnName="id",nullable=false)
*/
    protected $rol;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

public function setCliente(\Monse\ClientesBundle\Entity\Cliente $cliente)
    {
        $this->cliente = $cliente;
    }

    /**
     * Get cliente
     *
     * @return integer 
     */
    public function getCliente()
    {
        return $this->cliente;
    }

    /**
     * Set usuario
     *
     * @param string $usuario
     */
    public function setUsuario($usuario)
    {
        $this->usuario = $usuario;
    }

    /**
     * Get usuario
     *
     * @return string 
     */
    public function getUsuario()
    {
        return $this->usuario;
    }

    /**
     * Set email
     *
     * @param string $email
     */
    public function setEmail($email)
    {
        $this->email = $email;
    }

    /**
     * Get email
     *
     * @return string 
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Set contrasena
     *
     * @param string $contrasena
     */
    public function setPassword($password)
    {
        $this->password = $password;
    }

    /**
     * Get contrasena
     *
     * @return string 
     */
    public function getPassword()
    {
        return $this->password;
    }

    /**
     * Set salt
     *
     * @param string $salt
     */
    public function setSalt($salt)
    {
        $this->salt = $salt;
    }

    /**
     * Get salt
     *
     * @return string 
     */
    public function getSalt()
    {
        return $this->salt;
    }

    /**
     * Set ultimo_ingreso
     *
     * @param date $ultimoIngreso
     */
    public function setUltimoIngreso($ultimoIngreso)
    {
        $this->ultimo_ingreso = $ultimoIngreso;
    }

    /**
     * Get ultimo_ingreso
     *
     * @return date 
     */
    public function getUltimoIngreso()
    {
        return $this->ultimo_ingreso;
    }

    /**
     * Set fecha_alta
     *
     * @param date $fechaAlta
     */
    public function setFechaAlta($fechaAlta)
    {
        $this->fecha_alta = $fechaAlta;
    }

    /**
     * Get fecha_alta
     *
     * @return date 
     */
    public function getFechaAlta()
    {
        return $this->fecha_alta;
    }

    /**
     * Set rol
     *
     * @param integer $rol
     */
    public function setRol(\Monse\UsuariosBundle\Entity\Rol $rol)
    {
        $this->rol = $rol;
    }

    /**
     * Get rol
     *
     * @return integer 
     */
    public function getRol()
    {
        return $this->rol;
    }

    public function __construct()
    {
        $this->fecha_alta = new \DateTime();
    }

    function equals(\Symfony\Component\Security\Core\User\UserInterface $usuario)
    {
        return $this->getUsuario() == $usuario->getUsername();
    }

    function eraseCredentials()
    {
    }

    function getRoles()
    {
    }

    function getUsername()
    {
        return $this->getUsuario();
    }
}

and this is my roles entity

    <?php

namespace Monse\UsuariosBundle\Entity;

use Symfony\Component\Security\Core\Role\RoleInterface;
use Doctrine\ORM\Mapping as ORM;
/**
 * Monse\UsuariosBundle\Entity\Rol
 *
 * @ORM\Table(name="roles")
 * @ORM\Entity
 */
class Rol implements RoleInterface
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @var string $role
     *
     * @ORM\Column(name="rol", type="string", length=255)
     */
    protected $role;

    /**
     * @var string $denominacion
     *
     * @ORM\Column(name="denominacion", type="string", length=255)
     */
    protected $denominacion;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set rol
     *
     * @param string $rol
     */
    public function setRole($role)
    {
        $this->role = $role;
    }

    /**
     * Get rol
     *
     * @return string 
     */
    public function getRole()
    {
        return $this->role;
    }
     public function setDenominacion($denominacion)
    {
        $this->denominacion = $denominacion;
    }

    /**
     * Get denominacion
     *
     * @return string 
     */
    public function getDenominacion()
    {
        return $this->denominacion;
    }

    public function __toString() {
        return $this->denominacion;
    }
}

Please HELP, i don’t know what i’m doing wrong?

I need to administrate ROLES, that’s why i have the entity.

In the Rol entity

rol has ROLE_ADMIN, ROLE_USER…
denominacion is Super Admin, Admin, User, etc…
I need to retreive ROL

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:44:12+00:00Added an answer on June 16, 2026 at 12:44 am

    Function getRoles() in Usuario should return an array of role names. Why yours is empty?

    public function getRoles()
    {
        return $this->roles->map(function($r) { return $r->getRole(); })
            ->toArray();
    }
    

    Usuario has a many to one relation with role. Are you sure this is correct? The above example assumes that you have a collection of roles.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is my Entity: <?php namespace Trade\TradeBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as
I am using this in User.php use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert;
This is my code: // my article fixture <?php namespace My\BlogBundle\DataFixtures\ORM; use Doctrine\Common\DataFixtures\AbstractFixture; use
I have an Entity class that looks like this: <?php namespace Entities; /** @Entity
In our application, I have seen code written like this: User.java (User entity) public
mI've this entity class: @Entity public class User implements Serializable { @Id @GeneratedValue(strategy=GenerationType.AUTO) private
I have this error when I submit my form: Class Symfony\Component\Form\Form is not a
Ok, I have a User entity as follows <?php class User { /** *
I'm getting this error when I try to clear the cache (for example): [Doctrine\ORM\Mapping
I got the following entity use Gedmo\Timestampable\Traits\TimestampableEntity; /** * @ORM\Entity * @ORM\Table(name=users) * @UniqueEntity(fields=email,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.