<?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\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity(fields={"email"}, message="There is already an account with this email")
*/
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)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=255)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=100)
*/
private $phone;
/**
* @ORM\ManyToOne(targetEntity=Service::class, inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $service;
/**
* @ORM\ManyToOne(targetEntity=Category::class, inversedBy="users")
* @ORM\JoinColumn(nullable=true)
*/
private $category;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $society;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $job;
/**
* @ORM\Column(type="string", length=255)
*/
private $ask_object;
/**
* @ORM\Column(type="datetime")
*/
private $created_At;
/**
* @ORM\Column(type="datetime",nullable=true)
*/
private $updated_At;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $deleted_At;
/**
* @ORM\OneToMany(targetEntity=Booking::class, mappedBy="user")
*/
private $bookings;
/**
* @ORM\OneToMany(targetEntity=Bill::class, mappedBy="user")
*/
private $bills;
/**
* @ORM\OneToMany(targetEntity=Commentary::class, mappedBy="author")
*/
private $commentaries;
/**
* @ORM\OneToMany(targetEntity=Contact::class, mappedBy="user")
*/
private $contacts;
public function __construct()
{
$this->bookings = new ArrayCollection();
$this->bills = new ArrayCollection();
$this->articles = new ArrayCollection();
$this->commentaries = new ArrayCollection();
$this->contacts = 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 getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getService(): ?Service
{
return $this->service;
}
public function setService(?Service $service): self
{
$this->service = $service;
return $this;
}
public function getCategory(): ?Category
{
return $this->category;
}
public function setCategory(?Category $category): self
{
$this->category = $category;
return $this;
}
public function getSociety(): ?string
{
return $this->society;
}
public function setSociety(?string $society): self
{
$this->society = $society;
return $this;
}
public function getJob(): ?string
{
return $this->job;
}
public function setJob(?string $job): self
{
$this->job = $job;
return $this;
}
public function getAskObject(): ?string
{
return $this->ask_object;
}
public function setAskObject(string $ask_object): self
{
$this->ask_object = $ask_object;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_At;
}
public function setCreatedAt(\DateTimeInterface $created_At): self
{
$this->created_At = $created_At;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_At;
}
public function setUpdatedAt(\DateTimeInterface $updated_At): self
{
$this->updated_At = $updated_At;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deleted_At;
}
public function setDeletedAt(?\DateTimeInterface $deleted_At): self
{
$this->deleted_At = $deleted_At;
return $this;
}
/**
* @return Collection<int, Booking>
*/
public function getBookings(): Collection
{
return $this->bookings;
}
public function addBooking(Booking $booking): self
{
if (!$this->bookings->contains($booking)) {
$this->bookings[] = $booking;
$booking->setUser($this);
}
return $this;
}
public function removeBooking(Booking $booking): self
{
if ($this->bookings->removeElement($booking)) {
// set the owning side to null (unless already changed)
if ($booking->getUser() === $this) {
$booking->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Bill>
*/
public function getBills(): Collection
{
return $this->bills;
}
public function addBill(Bill $bill): self
{
if (!$this->bills->contains($bill)) {
$this->bills[] = $bill;
$bill->setUser($this);
}
return $this;
}
public function removeBill(Bill $bill): self
{
if ($this->bills->removeElement($bill)) {
// set the owning side to null (unless already changed)
if ($bill->getUser() === $this) {
$bill->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, Commentary>
*/
public function getCommentaries(): Collection
{
return $this->commentaries;
}
public function addCommentary(Commentary $commentary): self
{
if (!$this->commentaries->contains($commentary)) {
$this->commentaries[] = $commentary;
$commentary->setAuthor($this);
}
return $this;
}
public function removeCommentary(Commentary $commentary): self
{
if ($this->commentaries->removeElement($commentary)) {
// set the owning side to null (unless already changed)
if ($commentary->getAuthor() === $this) {
$commentary->setAuthor(null);
}
}
return $this;
}
/**
* @return Collection<int, Contact>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): self
{
if (!$this->contacts->contains($contact)) {
$this->contacts[] = $contact;
$contact->setUser($this);
}
return $this;
}
public function removeContact(Contact $contact): self
{
if ($this->contacts->removeElement($contact)) {
// set the owning side to null (unless already changed)
if ($contact->getUser() === $this) {
$contact->setUser(null);
}
}
return $this;
}
}