<?php
namespace App\Entity;
use App\Repository\UserRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use JsonSerializable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @ORM\Table(name="`users`")
* @UniqueEntity(fields={"usermane"}, message="There is already an account with this usermane")
* @method string getUserIdentifier()
*/
class User implements UserInterface, JsonSerializable
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180)
*/
private $usermane;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string", nullable=true)
*/
private $password;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $civility;
/**
* @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 $email;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $second_phone;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $adress;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $second_adress;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $region;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $city;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $tariff_category;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $zip;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $type;
/**
* @ORM\Column(type="boolean")
*/
private $isVerified = false;
/**
* @ORM\OneToMany(targetEntity=Link::class, mappedBy="user",cascade={"persist"})
*/
private $links;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="client")
*/
private $documents;
/**
* @ORM\OneToMany(targetEntity=Document::class, mappedBy="user")
*/
private $userDocuments;
/**
* @ORM\OneToMany(targetEntity=Address::class, mappedBy="user")
*/
private $multiAddress;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="user")
*/
private $comments;
/**
* @ORM\ManyToOne(targetEntity=Supplier::class, inversedBy="contacts")
*/
private $supplier;
/**
* @ORM\ManyToOne(targetEntity=Promotion::class, inversedBy="clients")
*/
private $promotion;
/**
* @ORM\OneToMany(targetEntity=Activity::class, mappedBy="currentUser")
* @ORM\OrderBy({"ceratedAt" = "DESC"})
*/
private $activities;
/**
* @ORM\ManyToOne(targetEntity=GroupUser::class, inversedBy="users")
*/
private $groupUser;
public function __construct()
{
$this->links = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->userDocuments = new ArrayCollection();
$this->multiAddress = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->activities = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUsermane(): ?string
{
return $this->usermane;
}
public function setUsermane(string $usermane): self
{
$this->usermane = $usermane;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->usermane;
}
/**
* @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 (string) $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 getCivility(): ?string
{
return $this->civility;
}
public function setCivility(string $civility): self
{
$this->civility = $civility;
return $this;
}
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;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getSecondPhone(): ?string
{
return $this->second_phone;
}
public function setSecondPhone(?string $second_phone): self
{
$this->second_phone = $second_phone;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(string $adress): self
{
$this->adress = $adress;
return $this;
}
public function getSecondAdress(): ?string
{
return $this->second_adress;
}
public function setSecondAdress(?string $second_adress): self
{
$this->second_adress = $second_adress;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getRegion(): ?string
{
return $this->region;
}
public function setRegion(string $region): self
{
$this->region = $region;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getTariffCategory(): ?string
{
return $this->tariff_category;
}
public function setTariffCategory(?string $tariff_category): self
{
$this->tariff_category = $tariff_category;
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(string $zip): self
{
$this->zip = $zip;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function isVerified(): bool
{
return $this->isVerified;
}
public function setIsVerified(bool $isVerified): self
{
$this->isVerified = $isVerified;
return $this;
}
/**
* @return Collection|Link[]
*/
public function getLinks(): Collection
{
return $this->links;
}
public function addLink(Link $link): self
{
if (!$this->links->contains($link)) {
$this->links[] = $link;
$link->setUser($this);
}
return $this;
}
public function removeLink(Link $link): self
{
if ($this->links->removeElement($link)) {
// set the owning side to null (unless already changed)
if ($link->getUser() === $this) {
$link->setUser(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection|Document[]
*/
public function getDocuments(): Collection
{
return $this->documents;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents[] = $document;
$document->setClient($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->removeElement($document)) {
// set the owning side to null (unless already changed)
if ($document->getClient() === $this) {
$document->setClient(null);
}
}
return $this;
}
/**
* @return Collection|Document[]
*/
public function getUserDocuments(): Collection
{
return $this->userDocuments;
}
public function addUserDocument(Document $userDocument): self
{
if (!$this->userDocuments->contains($userDocument)) {
$this->userDocuments[] = $userDocument;
$userDocument->setUser($this);
}
return $this;
}
public function removeUserDocument(Document $userDocument): self
{
if ($this->userDocuments->removeElement($userDocument)) {
// set the owning side to null (unless already changed)
if ($userDocument->getUser() === $this) {
$userDocument->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Address[]
*/
public function getMultiAddress(): Collection
{
return $this->multiAddress;
}
public function addMultiAddress(Address $multiAddress): self
{
if (!$this->multiAddress->contains($multiAddress)) {
$this->multiAddress[] = $multiAddress;
$multiAddress->setUser($this);
}
return $this;
}
public function removeMultiAddress(Address $multiAddress): self
{
if ($this->multiAddress->removeElement($multiAddress)) {
// set the owning side to null (unless already changed)
if ($multiAddress->getUser() === $this) {
$multiAddress->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setUser($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getUser() === $this) {
$comment->setUser(null);
}
}
return $this;
}
public function getSupplier(): ?Supplier
{
return $this->supplier;
}
public function setSupplier(?Supplier $supplier): self
{
$this->supplier = $supplier;
return $this;
}
public function getPromotion(): ?Promotion
{
return $this->promotion;
}
public function setPromotion(?Promotion $promotion): self
{
$this->promotion = $promotion;
return $this;
}
/**
* @return Collection|Activity[]
*/
public function getActivities(): Collection
{
return $this->activities;
}
public function addActivity(Activity $activity): self
{
if (!$this->activities->contains($activity)) {
$this->activities[] = $activity;
$activity->setCurrentUser($this);
}
return $this;
}
public function removeActivity(Activity $activity): self
{
if ($this->activities->removeElement($activity)) {
// set the owning side to null (unless already changed)
if ($activity->getCurrentUser() === $this) {
$activity->setCurrentUser(null);
}
}
return $this;
}
public function getGroupUser(): ?GroupUser
{
return $this->groupUser;
}
public function setGroupUser(?GroupUser $groupUser): self
{
$this->groupUser = $groupUser;
return $this;
}
public function __call($name, $arguments)
{
// TODO: Implement @method string getUserIdentifier()
}
public function jsonSerialize()
{
return array(
'adress' => $this->getAdress(),
'second_adress' => $this->getSecondAdress(),
'firstName' => $this->getFirstName(),
'lastName' => $this->getLastName(),
'username' => $this->getUsermane(),
'email' => $this->getEmail(),
'password' => '',
'newPassword' => '',
'confirmPassword' => ''
);
}
}