src/Entity/User.php line 20
<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
#[ORM\Entity(repositoryClass: UserRepository::class)]
#[ORM\Table(name: '`user`')]
#[UniqueEntity(fields: ['email'], message: 'There is already an account with this email')]
#[Vich\Uploadable]
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 180, unique: true)]
private ?string $email = null;
#[ORM\Column]
private array $roles = [];
/**
* @var string The hashed password
*/
#[ORM\Column]
private ?string $password = null;
#[ORM\Column(type: 'boolean')]
private $isVerified = false;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255)]
private ?string $firstname = null;
#[ORM\Column(length: 255)]
private ?string $phone = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image = null;
#[Vich\UploadableField(mapping: 'users_images', fileNameProperty: 'image')]
private ?File $imageFile = null;
#[ORM\ManyToOne(targetEntity: self::class, cascade: ['remove'], inversedBy: 'users')]
#[ORM\JoinColumn(name: 'administrator_id', referencedColumnName: 'id', onDelete: 'CASCADE')]
private ?self $administrator = null;
#[ORM\OneToMany(mappedBy: 'administrator', targetEntity: self::class)]
private Collection $users;
#[ORM\ManyToMany(targetEntity: Program::class, mappedBy: 'collaborators')]
private Collection $programs;
#[ORM\OneToMany(mappedBy: 'adminUser', targetEntity: Client::class)]
private Collection $clients;
#[ORM\OneToMany(mappedBy: 'adminUser', targetEntity: Company::class)]
private Collection $companies;
#[ORM\OneToMany(mappedBy: 'adminUser', targetEntity: Groupe::class)]
private Collection $groupes;
#[ORM\OneToOne(mappedBy: 'userClient', targetEntity: Client::class)]
private ?Client $client = null;
#[ORM\Column]
private ?bool $isDisable = null;
public function __construct()
{
$this->users = new ArrayCollection();
$this->programs = new ArrayCollection();
$this->clients = new ArrayCollection();
$this->companies = new ArrayCollection();
$this->groupes = new ArrayCollection();
$this->isDisable = false;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string|null $name
*/
public function setName(?string $name): void
{
$this->name = $name;
}
/**
* @return string|null
*/
public function getFirstname(): ?string
{
return $this->firstname;
}
/**
* @param string|null $firstname
*/
public function setFirstname(?string $firstname): void
{
$this->firstname = $firstname;
}
/**
* @return string|null
*/
public function getPhone(): ?string
{
return $this->phone;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'CandidateFile' as the bundle will inject one here
* during Doctrine hydration.
*
* @param CandidateFile|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
*/
public function setImageFile(?File $imageFile = null): void
{
$this->imageFile = $imageFile;
if (null !== $imageFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
}
public function getImageFile(): ?File
{
return $this->imageFile;
}
/**
* @param string|null $phone
*/
public function setPhone(?string $phone): void
{
$this->phone = $phone;
}
/**
* @return string|null
*/
public function getImage(): ?string
{
return $this->image;
}
/**
* @param string|null $image
*/
public function setImage(?string $image): void
{
$this->image = $image;
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUserIdentifier(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
/**
* @see PasswordAuthenticatedUserInterface
*/
public function getPassword(): string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
public function getAdministrator(): ?self
{
return $this->administrator;
}
public function setAdministrator(?self $administrator): self
{
$this->administrator = $administrator;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(self $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setAdministrator($this);
}
return $this;
}
public function removeUser(self $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getAdministrator() === $this) {
$user->setAdministrator(null);
}
}
return $this;
}
/**
* @return Collection<int, Program>
*/
public function getPrograms(): Collection
{
return $this->programs;
}
public function addProgram(Program $program): self
{
if (!$this->programs->contains($program)) {
$this->programs->add($program);
$program->addCollaborator($this);
}
return $this;
}
public function removeProgram(Program $program): self
{
if ($this->programs->removeElement($program)) {
$program->removeCollaborator($this);
}
return $this;
}
/**
* @return Collection<int, Client>
*/
public function getClients(): Collection
{
return $this->clients;
}
public function addClient(Client $client): self
{
if (!$this->clients->contains($client)) {
$this->clients->add($client);
$client->setAdminUser($this);
}
return $this;
}
public function removeClient(Client $client): self
{
if ($this->clients->removeElement($client)) {
// set the owning side to null (unless already changed)
if ($client->getAdminUser() === $this) {
$client->setAdminUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Company>
*/
public function getCompanies(): Collection
{
return $this->companies;
}
public function addCompany(Company $company): self
{
if (!$this->companies->contains($company)) {
$this->companies->add($company);
$company->setAdminUser($this);
}
return $this;
}
public function removeCompany(Company $company): self
{
if ($this->companies->removeElement($company)) {
// set the owning side to null (unless already changed)
if ($company->getAdminUser() === $this) {
$company->setAdminUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Groupe>
*/
public function getGroupes(): Collection
{
return $this->groupes;
}
public function addGroupe(Groupe $groupe): self
{
if (!$this->groupes->contains($groupe)) {
$this->groupes->add($groupe);
$groupe->setAdminUser($this);
}
return $this;
}
public function removeGroupe(Groupe $groupe): self
{
if ($this->groupes->removeElement($groupe)) {
// set the owning side to null (unless already changed)
if ($groupe->getAdminUser() === $this) {
$groupe->setAdminUser(null);
}
}
return $this;
}
/**
* @return Client|null
*/
public function getClient(): ?Client
{
return $this->client;
}
/**
* @param Client|null $client
*/
public function setClient(?Client $client): void
{
$this->client = $client;
}
public function isIsDisable(): ?bool
{
return $this->isDisable;
}
public function setIsDisable(bool $isDisable): self
{
$this->isDisable = $isDisable;
return $this;
}
}