src/Entity/User/AdminUser.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\User;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
  5. use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
  6. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  7. use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
  8. use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
  9. use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu;
  10. use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface;
  11. use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface;
  12. use phpDocumentor\Reflection\Types\This;
  13. use Symfony\Component\HttpFoundation\Response;
  14. use Symfony\Component\Security\Core\User\UserInterface;
  15. #[ORM\Table(name'admin_user')]
  16. #[ORM\Entity(repositoryClass\App\Repository\User\AdminUserRepository::class)]
  17. class AdminUser implements UserInterface\Serializable
  18. {
  19.     #[ORM\Column(type'integer')]
  20.     #[ORM\Id]
  21.     #[ORM\GeneratedValue(strategy'AUTO')]
  22.     private $id;
  23.     #[ORM\Column(type'string'length255)]
  24.     private $nom;
  25.     #[ORM\Column(type'string'length255)]
  26.     private $prenom;
  27.     #[ORM\Column(type'string'length25uniquetrue)]
  28.     private $username;
  29.     #[ORM\Column(type'string'length64)]
  30.     private $password;
  31.     #[ORM\Column(type'string'length254uniquetrue)]
  32.     private $email;
  33.     #[ORM\Column(type'array'length255)]
  34.     private array $roles = [];
  35.     #[ORM\Column(name'is_active'type'boolean')]
  36.     private bool $isActive true;
  37.     #[ORM\Column(name'created_at'type'datetime')]
  38.     private $created_at;
  39.     #[ORM\Column(name'fournisseur'type'boolean'nullabletrue)]
  40.     private $fournisseur;
  41.     #[ORM\Column(name'id_fournisseur'type'integer'nullabletrue)]
  42.     private $idFournisseur;
  43.     #[ORM\Column(type'string'length255)]
  44.     private $image;
  45.     public function __construct()
  46.     {
  47.         $this->created_at = new \DateTime("now");
  48.     }
  49.     public function getSalt()
  50.     {
  51.         // TODO: Implement getSalt() method.
  52.     }
  53.     public function getUsername()
  54.     {
  55.         return $this->username;
  56.     }
  57.     public function getEmail()
  58.     {
  59.         return $this->email;
  60.     }
  61.     public function getPassword()
  62.     {
  63.         return $this->password;
  64.     }
  65.     public function getRoles()
  66.     {
  67.         $roles $this->roles;
  68.         return array_unique($roles);
  69.     }
  70.     public function hasRole($role)
  71.     {
  72.         var_dump(strtoupper((string) $role));
  73.         var_dump($this->getRoles());
  74.         return true;
  75.     }
  76.     public function addRole($role)
  77.     {
  78.         $role strtoupper((string) $role);
  79.         if (!in_array($role$this->rolestrue)) {
  80.             $this->roles[] = $role;
  81.         }
  82.         return $this;
  83.     }
  84.     /**
  85.      * Set role
  86.      *
  87.      * @param array $roles
  88.      *
  89.      * @return AdminUser
  90.      */
  91.     public function SetRoles($roles)
  92.     {
  93.         $this->roles = [];
  94.         foreach($roles as $role){
  95.             $role strtoupper((string) $role);
  96.             if (!in_array($role$this->rolestrue)) {
  97.                 $this->roles[] = $role;
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     public function eraseCredentials()
  103.     {
  104.     }
  105.     /** @see \Serializable::serialize() */
  106.     public function serialize()
  107.     {
  108.         return serialize([
  109.             $this->id,
  110.             $this->username,
  111.             $this->password,
  112.             // see section on salt below
  113.             // $this->salt,
  114.         ]);
  115.     }
  116.     /** @see \Serializable::unserialize() */
  117.     public function unserialize($serialized)
  118.     {
  119.         [$this->id$this->username$this->password, ] = unserialize($serialized);
  120.     }
  121.     /**
  122.      * Get id
  123.      *
  124.      * @return integer
  125.      */
  126.     public function getId()
  127.     {
  128.         return $this->id;
  129.     }
  130.     /**
  131.      * Set username
  132.      *
  133.      * @param string $username
  134.      *
  135.      * @return AdminUser
  136.      */
  137.     public function setUsername($username)
  138.     {
  139.         $this->username $username;
  140.         return $this;
  141.     }
  142.     /**
  143.      * Set password
  144.      *
  145.      * @param string $password
  146.      *
  147.      * @return AdminUser
  148.      */
  149.     public function setPassword($password)
  150.     {
  151.         $this->password $password;
  152.         return $this;
  153.     }
  154.     /**
  155.      * Set email
  156.      *
  157.      * @param string $email
  158.      *
  159.      * @return AdminUser
  160.      */
  161.     public function setEmail($email)
  162.     {
  163.         $this->email $email;
  164.         return $this;
  165.     }
  166.     /**
  167.      * Set isActive
  168.      *
  169.      * @param boolean $isActive
  170.      *
  171.      * @return AdminUser
  172.      */
  173.     public function setIsActive($isActive)
  174.     {
  175.         $this->isActive $isActive;
  176.         return $this;
  177.     }
  178.     /**
  179.      * Get isActive
  180.      *
  181.      * @return boolean
  182.      */
  183.     public function getIsActive()
  184.     {
  185.         return $this->isActive;
  186.     }
  187.     public function getImage()
  188.     {
  189.         return $this->image;
  190.     }
  191.     public function setImage($image)
  192.     {
  193.         $this->image $image;
  194.         return $this;
  195.     }
  196.     public function getNom()
  197.     {
  198.         return $this->nom;
  199.     }
  200.     public function setNom($nom)
  201.     {
  202.         $this->nom $nom;
  203.         return $this;
  204.     }
  205.     public function getPrenom()
  206.     {
  207.         return $this->prenom;
  208.     }
  209.     public function setPrenom($prenom)
  210.     {
  211.         $this->prenom $prenom;
  212.         return $this;
  213.     }
  214.     /**
  215.      * Set createdAt
  216.      *
  217.      * @param \DateTime $createdAt
  218.      *
  219.      * @return AdminUser
  220.      */
  221.     public function setCreatedAt($createdAt)
  222.     {
  223.         $this->created_at $createdAt;
  224.         return $this;
  225.     }
  226.     /**
  227.      * Get createdAt
  228.      *
  229.      * @return \DateTime
  230.      */
  231.     public function getCreatedAt()
  232.     {
  233.         return $this->created_at;
  234.     }
  235.     /**
  236.      * Set fournisseur
  237.      *
  238.      * @param boolean $fournisseur
  239.      *
  240.      * @return AdminUser
  241.      */
  242.     public function setFournisseur($fournisseur)
  243.     {
  244.         $this->fournisseur $fournisseur;
  245.         return $this;
  246.     }
  247.     /**
  248.      * Get fournisseur
  249.      *
  250.      * @return boolean
  251.      */
  252.     public function getFournisseur()
  253.     {
  254.         return $this->fournisseur;
  255.     }
  256.     /**
  257.      * Set idFournisseur
  258.      *
  259.      * @param integer $idFournisseur
  260.      *
  261.      * @return AdminUser
  262.      */
  263.     public function setIdFournisseur($idFournisseur)
  264.     {
  265.         $this->idFournisseur $idFournisseur;
  266.         return $this;
  267.     }
  268.     /**
  269.      * Get idFournisseur
  270.      *
  271.      * @return integer
  272.      */
  273.     public function getIdFournisseur()
  274.     {
  275.         return $this->idFournisseur;
  276.     }
  277.     public function getFullName()
  278.     {
  279.         return $this->getNom().' '.$this->getPrenom();
  280.     }
  281. }