<?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\UserInterface;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\HasLifecycleCallbacks()
* @Vich\Uploadable
*/
class User implements UserInterface, \Serializable
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $firstName;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastName;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
/**
* @ORM\ManyToOne(targetEntity=Profile::class, inversedBy="UserId")
* @ORM\JoinColumn(nullable=false)
*/
private $profile;
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Vich\UploadableField(mapping="user_image", fileNameProperty="image")
*
* @var File|null
*/
private $imageFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @ORM\OneToMany(targetEntity=CarBuy::class, mappedBy="user")
*/
private $carBuyId;
/**
* @ORM\OneToMany(targetEntity=CarSale::class, mappedBy="user")
*/
private $CarSaleId;
/**
* @ORM\OneToMany(targetEntity=Client::class, mappedBy="user")
*/
private $client;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $agencyDaysNotification;
/**
* @ORM\OneToMany(targetEntity=CarResale::class, mappedBy="user")
*/
private $carResales;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $AllowUser;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowClients;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowVehicles;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowVehiclesBuys;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowVehiclesSales;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowVehiclesResales;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowAgency;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowAdministration;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowTransfers;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $allowSystem;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $cellphone;
public function __construct()
{
$this->carBuyId = new ArrayCollection();
$this->CarSaleId = new ArrayCollection();
$this->client = new ArrayCollection();
$this->carResales = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
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 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 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 UserInterface
*/
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 getProfile(): ?Profile
{
return $this->profile;
}
public function setProfile(?Profile $profile): self
{
$this->profile = $profile;
return $this;
}
/**
* 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 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\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;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getCreatedAt(): ?\DateTime
{
return $this->createdAt;
}
/**
* @ORM\PrePersist
*/
//public function setCreatedAt(\DateTime $createdAt): self
public function setCreatedAt(): self
{
$this->createdAt = new \DateTime();
return $this;
}
public function getUpdatedAt(): ?\DateTime
{
return $this->updatedAt;
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAt(): self
{
$this->updatedAt = new \DateTime();
return $this;
}
public function serialize()
{
return serialize(array(
$this->id,
$this->email,
$this->password,
));
}
public function unserialize($serialized)
{
list(
$this->id,
$this->email,
$this->password,
) = unserialize($serialized);
}
/**
* @return Collection|CarBuy[]
*/
public function getCarBuyId(): Collection
{
return $this->carBuyId;
}
public function addCarBuyId(CarBuy $carBuyId): self
{
if (!$this->carBuyId->contains($carBuyId)) {
$this->carBuyId[] = $carBuyId;
$carBuyId->setUser($this);
}
return $this;
}
public function removecarBuyId(CarBuy $carBuyId): self
{
if ($this->carBuyId->removeElement($carBuyId)) {
// set the owning side to null (unless already changed)
if ($carBuyId->getUser() === $this) {
$carBuyId->setUser(null);
}
}
return $this;
}
/**
* @return Collection|CarSale[]
*/
public function getCarSaleId(): Collection
{
return $this->CarSaleId;
}
public function addCarSaleId(CarSale $carSaleId): self
{
if (!$this->CarSaleId->contains($carSaleId)) {
$this->CarSaleId[] = $carSaleId;
$carSaleId->setUser($this);
}
return $this;
}
public function removeCarSaleId(CarSale $carSaleId): self
{
if ($this->CarSaleId->removeElement($carSaleId)) {
// set the owning side to null (unless already changed)
if ($carSaleId->getUser() === $this) {
$carSaleId->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Client[]
*/
public function getClient(): Collection
{
return $this->client;
}
public function addClient(Client $client): self
{
if (!$this->client->contains($client)) {
$this->client[] = $client;
$client->setUser($this);
}
return $this;
}
public function removeClient(Client $client): self
{
if ($this->client->removeElement($client)) {
// set the owning side to null (unless already changed)
if ($client->getUser() === $this) {
$client->setUser(null);
}
}
return $this;
}
public function getAgencyDaysNotification(): ?int
{
return $this->agencyDaysNotification;
}
public function setAgencyDaysNotification(?int $agencyDaysNotification): self
{
$this->agencyDaysNotification = $agencyDaysNotification;
return $this;
}
/**
* @return Collection<int, CarResale>
*/
public function getCarResales(): Collection
{
return $this->carResales;
}
public function addCarResale(CarResale $carResale): self
{
if (!$this->carResales->contains($carResale)) {
$this->carResales[] = $carResale;
$carResale->setUser($this);
}
return $this;
}
public function removeCarResale(CarResale $carResale): self
{
if ($this->carResales->removeElement($carResale)) {
// set the owning side to null (unless already changed)
if ($carResale->getUser() === $this) {
$carResale->setUser(null);
}
}
return $this;
}
public function getAllowUser(): ?bool
{
return $this->AllowUser;
}
public function setAllowUser(?bool $AllowUser): self
{
$this->AllowUser = $AllowUser;
return $this;
}
public function getAllowClients(): ?bool
{
return $this->allowClients;
}
public function setAllowClients(?bool $allowClients): self
{
$this->allowClients = $allowClients;
return $this;
}
public function getAllowVehicles(): ?bool
{
return $this->allowVehicles;
}
public function setAllowVehicles(?bool $allowVehicles): self
{
$this->allowVehicles = $allowVehicles;
return $this;
}
public function getAllowVehiclesBuys(): ?bool
{
return $this->allowVehiclesBuys;
}
public function setAllowVehiclesBuys(?bool $allowVehiclesBuys): self
{
$this->allowVehiclesBuys = $allowVehiclesBuys;
return $this;
}
public function getAllowVehiclesSales(): ?bool
{
return $this->allowVehiclesSales;
}
public function setAllowVehiclesSales(?bool $allowVehiclesSales): self
{
$this->allowVehiclesSales = $allowVehiclesSales;
return $this;
}
public function getAllowVehiclesResales(): ?bool
{
return $this->allowVehiclesResales;
}
public function setAllowVehiclesResales(?bool $allowVehiclesResales): self
{
$this->allowVehiclesResales = $allowVehiclesResales;
return $this;
}
public function getAllowAgency(): ?bool
{
return $this->allowAgency;
}
public function setAllowAgency(?bool $allowAgency): self
{
$this->allowAgency = $allowAgency;
return $this;
}
public function getAllowAdministration(): ?bool
{
return $this->allowAdministration;
}
public function setAllowAdministration(?bool $allowAdministration): self
{
$this->allowAdministration = $allowAdministration;
return $this;
}
public function getAllowTransfers(): ?bool
{
return $this->allowTransfers;
}
public function setAllowTransfers(?bool $allowTransfers): self
{
$this->allowTransfers = $allowTransfers;
return $this;
}
public function getAllowSystem(): ?bool
{
return $this->allowSystem;
}
public function setAllowSystem(?bool $allowSystem): self
{
$this->allowSystem = $allowSystem;
return $this;
}
public function getCellphone(): ?string
{
return $this->cellphone;
}
public function setCellphone(?string $cellphone): self
{
$this->cellphone = $cellphone;
return $this;
}
}