<?php
namespace App\Entity\User;
use Doctrine\ORM\Mapping as ORM;
use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
use EasyCorp\Bundle\EasyAdminBundle\Config\Assets;
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Config\Dashboard;
use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
use EasyCorp\Bundle\EasyAdminBundle\Config\UserMenu;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Controller\DashboardControllerInterface;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Menu\MenuItemInterface;
use phpDocumentor\Reflection\Types\This;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\User\UserInterface;
#[ORM\Table(name: 'admin_user')]
#[ORM\Entity(repositoryClass: \App\Repository\User\AdminUserRepository::class)]
class AdminUser implements UserInterface, \Serializable
{
#[ORM\Column(type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $nom;
#[ORM\Column(type: 'string', length: 255)]
private $prenom;
#[ORM\Column(type: 'string', length: 25, unique: true)]
private $username;
#[ORM\Column(type: 'string', length: 64)]
private $password;
#[ORM\Column(type: 'string', length: 254, unique: true)]
private $email;
#[ORM\Column(type: 'array', length: 255)]
private array $roles = [];
#[ORM\Column(name: 'is_active', type: 'boolean')]
private bool $isActive = true;
#[ORM\Column(name: 'created_at', type: 'datetime')]
private $created_at;
#[ORM\Column(name: 'fournisseur', type: 'boolean', nullable: true)]
private $fournisseur;
#[ORM\Column(name: 'id_fournisseur', type: 'integer', nullable: true)]
private $idFournisseur;
#[ORM\Column(type: 'string', length: 255)]
private $image;
public function __construct()
{
$this->created_at = new \DateTime("now");
}
public function getSalt()
{
// TODO: Implement getSalt() method.
}
public function getUsername()
{
return $this->username;
}
public function getEmail()
{
return $this->email;
}
public function getPassword()
{
return $this->password;
}
public function getRoles()
{
$roles = $this->roles;
return array_unique($roles);
}
public function hasRole($role)
{
var_dump(strtoupper((string) $role));
var_dump($this->getRoles());
return true;
}
public function addRole($role)
{
$role = strtoupper((string) $role);
if (!in_array($role, $this->roles, true)) {
$this->roles[] = $role;
}
return $this;
}
/**
* Set role
*
* @param array $roles
*
* @return AdminUser
*/
public function SetRoles($roles)
{
$this->roles = [];
foreach($roles as $role){
$role = strtoupper((string) $role);
if (!in_array($role, $this->roles, true)) {
$this->roles[] = $role;
}
}
return $this;
}
public function eraseCredentials()
{
}
/** @see \Serializable::serialize() */
public function serialize()
{
return serialize([
$this->id,
$this->username,
$this->password,
// see section on salt below
// $this->salt,
]);
}
/** @see \Serializable::unserialize() */
public function unserialize($serialized)
{
[$this->id, $this->username, $this->password, ] = unserialize($serialized);
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set username
*
* @param string $username
*
* @return AdminUser
*/
public function setUsername($username)
{
$this->username = $username;
return $this;
}
/**
* Set password
*
* @param string $password
*
* @return AdminUser
*/
public function setPassword($password)
{
$this->password = $password;
return $this;
}
/**
* Set email
*
* @param string $email
*
* @return AdminUser
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Set isActive
*
* @param boolean $isActive
*
* @return AdminUser
*/
public function setIsActive($isActive)
{
$this->isActive = $isActive;
return $this;
}
/**
* Get isActive
*
* @return boolean
*/
public function getIsActive()
{
return $this->isActive;
}
public function getImage()
{
return $this->image;
}
public function setImage($image)
{
$this->image = $image;
return $this;
}
public function getNom()
{
return $this->nom;
}
public function setNom($nom)
{
$this->nom = $nom;
return $this;
}
public function getPrenom()
{
return $this->prenom;
}
public function setPrenom($prenom)
{
$this->prenom = $prenom;
return $this;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return AdminUser
*/
public function setCreatedAt($createdAt)
{
$this->created_at = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->created_at;
}
/**
* Set fournisseur
*
* @param boolean $fournisseur
*
* @return AdminUser
*/
public function setFournisseur($fournisseur)
{
$this->fournisseur = $fournisseur;
return $this;
}
/**
* Get fournisseur
*
* @return boolean
*/
public function getFournisseur()
{
return $this->fournisseur;
}
/**
* Set idFournisseur
*
* @param integer $idFournisseur
*
* @return AdminUser
*/
public function setIdFournisseur($idFournisseur)
{
$this->idFournisseur = $idFournisseur;
return $this;
}
/**
* Get idFournisseur
*
* @return integer
*/
public function getIdFournisseur()
{
return $this->idFournisseur;
}
public function getFullName()
{
return $this->getNom().' '.$this->getPrenom();
}
}