<?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\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string") */
private $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $avatar;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $avtatarFilename;
/**
* @ORM\OneToMany(targetEntity=Employee::class, mappedBy="owner")
*/
private $employees;
/**
* @ORM\OneToMany(targetEntity=EstimatedExpenses::class, mappedBy="owner")
*/
private $estimated_expenses;
/**
* @ORM\OneToMany(targetEntity=Parameters::class, mappedBy="owner")
*/
private $parameters;
/**
* @ORM\OneToMany(targetEntity=Archives::class, mappedBy="owner")
*/
private $archives;
/**
* @ORM\OneToMany(targetEntity=AccountingPlan::class, mappedBy="owner")
*/
private $accountingPlans;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $resetToken;
/**
* @ORM\OneToMany(targetEntity=Quote::class, mappedBy="owner")
*/
private $quotes;
/**
* @ORM\OneToOne(targetEntity=Company::class, mappedBy="owner", cascade={"persist", "remove"})
*/
private $company;
/**
* @ORM\OneToMany(targetEntity=Product::class, mappedBy="owner")
*/
private $products;
/**
* @ORM\OneToMany(targetEntity=Client::class, mappedBy="owner")
*/
private $clients;
/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;
public function __construct()
{
$this->employees = new ArrayCollection();
$this->estimated_expenses = new ArrayCollection();
$this->parameters = new ArrayCollection();
$this->archives = new ArrayCollection();
$this->accountingPlans = new ArrayCollection();
$this->quotes = new ArrayCollection();
$this->products = new ArrayCollection();
$this->clients = new ArrayCollection();
}
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;
}
/**
* @deprecated since Symfony 5.3, use getUserIdentifier instead
*/
public function getUsername(): 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;
}
/**
* Returning a salt is only needed, if you are not using a modern
* hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
*
* @see UserInterface
*/
public function getSalt(): ?string
{
return null;
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(?string $lastname): self
{
$this->lastname = $lastname;
return $this;
}
public function getAvatar(): ?string
{
return $this->avatar;
}
public function setAvatar(?string $avatar): self
{
$this->avatar = $avatar;
return $this;
}
public function getAvtatarFilename(): ?string
{
return $this->avtatarFilename;
}
public function setAvtatarFilename(?string $avtatarFilename): self
{
$this->avtatarFilename = $avtatarFilename;
return $this;
}
/**
* @return Collection<int, Employee>
*/
public function getEmployees(): Collection
{
return $this->employees;
}
public function addEmployee(Employee $employee): self
{
if (!$this->employees->contains($employee)) {
$this->employees[] = $employee;
$employee->setOwner($this);
}
return $this;
}
public function removeEmployee(Employee $employee): self
{
if ($this->employees->removeElement($employee)) {
// set the owning side to null (unless already changed)
if ($employee->getOwner() === $this) {
$employee->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, EstimatedExpenses>
*/
public function getEstimatedExpenses(): Collection
{
return $this->estimated_expenses;
}
public function addEstimatedExpense(EstimatedExpenses $estimatedExpense): self
{
if (!$this->estimated_expenses->contains($estimatedExpense)) {
$this->estimated_expenses[] = $estimatedExpense;
$estimatedExpense->setOwner($this);
}
return $this;
}
public function removeEstimatedExpense(EstimatedExpenses $estimatedExpense): self
{
if ($this->estimated_expenses->removeElement($estimatedExpense)) {
// set the owning side to null (unless already changed)
if ($estimatedExpense->getOwner() === $this) {
$estimatedExpense->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, Parameters>
*/
public function getParameters(): Collection
{
return $this->parameters;
}
public function addParameter(Parameters $parameter): self
{
if (!$this->parameters->contains($parameter)) {
$this->parameters[] = $parameter;
$parameter->setOwner($this);
}
return $this;
}
public function removeParameter(Parameters $parameter): self
{
if ($this->parameters->removeElement($parameter)) {
// set the owning side to null (unless already changed)
if ($parameter->getOwner() === $this) {
$parameter->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, Archives>
*/
public function getArchives(): Collection
{
return $this->archives;
}
public function addArchive(Archives $archive): self
{
if (!$this->archives->contains($archive)) {
$this->archives[] = $archive;
$archive->setOwner($this);
}
return $this;
}
public function removeArchive(Archives $archive): self
{
if ($this->archives->removeElement($archive)) {
// set the owning side to null (unless already changed)
if ($archive->getOwner() === $this) {
$archive->setOwner(null);
}
}
return $this;
}
/**
* @return Collection<int, AccountingPlan>
*/
public function getAccountingPlans(): Collection
{
return $this->accountingPlans;
}
public function addAccountingPlan(AccountingPlan $accountingPlan): self
{
if (!$this->accountingPlans->contains($accountingPlan)) {
$this->accountingPlans[] = $accountingPlan;
$accountingPlan->setOwner($this);
}
return $this;
}
public function removeAccountingPlan(AccountingPlan $accountingPlan): self
{
if ($this->accountingPlans->removeElement($accountingPlan)) {
// set the owning side to null (unless already changed)
if ($accountingPlan->getOwner() === $this) {
$accountingPlan->setOwner(null);
}
}
return $this;
}
public function getResetToken(): ?string
{
return $this->resetToken;
}
public function setResetToken(?string $resetToken): self
{
$this->resetToken = $resetToken;
return $this;
}
/**
* @return Collection<int, Quote>
*/
public function getQuotes(): Collection
{
return $this->quotes;
}
public function addQuote(Quote $quote): self
{
if (!$this->quotes->contains($quote)) {
$this->quotes[] = $quote;
$quote->setOwner($this);
}
return $this;
}
public function removeQuote(Quote $quote): self
{
if ($this->quotes->removeElement($quote)) {
// set the owning side to null (unless already changed)
if ($quote->getOwner() === $this) {
$quote->setOwner(null);
}
}
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
// unset the owning side of the relation if necessary
if ($company === null && $this->company !== null) {
$this->company->setOwner(null);
}
// set the owning side of the relation if necessary
if ($company !== null && $company->getOwner() !== $this) {
$company->setOwner($this);
}
$this->company = $company;
return $this;
}
/**
* @return Collection<int, Product>
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->setOwner($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->removeElement($product)) {
// set the owning side to null (unless already changed)
if ($product->getOwner() === $this) {
$product->setOwner(null);
}
}
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[] = $client;
$client->setOwner($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->getOwner() === $this) {
$client->setOwner(null);
}
}
return $this;
}
public function isIsVerified(): ?bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
}