<?php
namespace App\Entity;
use App\Repository\ClientRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: ClientRepository::class)]
class Client
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(["getClient", "getProject", "getContact", "getReservation"])]
private ?int $id = null;
#[ORM\Column(length: 45)]
#[Groups(["getClient", "getProject", "getContact", "getReservation", "getTimes"])]
private ?string $name = null;
#[ORM\Column]
#[Groups(["getClient"])]
private ?bool $active = null;
#[ORM\Column(length: 6)]
#[Groups(["getTimes", "getClient", "getProject", "getContact"])]
private ?string $color = null;
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'clients')]
private Collection $users;
#[ORM\OneToMany(mappedBy: 'client', targetEntity: Project::class)]
#[Groups(["getClient"])]
private Collection $projects;
#[ORM\OneToMany(mappedBy: 'client', targetEntity: Contact::class)]
private Collection $contacts;
#[ORM\OneToMany(mappedBy: 'client', targetEntity: ClosureClient::class)]
private Collection $closuresClient;
public function __construct()
{
$this->users = new ArrayCollection();
$this->projects = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->closuresClient = new ArrayCollection();
}
public function __toString(): string
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
public function getColor(): ?string
{
return $this->color;
}
public function setColor(?string $color): void
{
$this->color = $color;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeClient($this);
}
return $this;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->addClient($this);
}
return $this;
}
/**
* @return Collection<int, Project>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function isActive(): ?bool
{
return $this->active;
}
public function addProject(Project $project): self
{
if (!$this->projects->contains($project)) {
$this->projects->add($project);
$project->setClient($this);
}
return $this;
}
public function removeProject(Project $project): self
{
if ($this->projects->removeElement($project)) {
if ($project->getClient() === $this) {
$project->setClient(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->add($contact);
$contact->setClient($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->getClient() === $this) {
$contact->setClient(null);
}
}
return $this;
}
/**
* @return Collection<int, ClosureClient>
*/
public function getClosuresClient(): Collection
{
return $this->closuresClient;
}
public function addClosuresClient(ClosureClient $closuresClient): self
{
if (!$this->closuresClient->contains($closuresClient)) {
$this->closuresClient->add($closuresClient);
$closuresClient->setClient($this);
}
return $this;
}
public function removeClosuresClient(ClosureClient $closuresClient): self
{
if ($this->closuresClient->removeElement($closuresClient)) {
// set the owning side to null (unless already changed)
if ($closuresClient->getClient() === $this) {
$closuresClient->setClient(null);
}
}
return $this;
}
}