src/Entity/Client.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClientRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. #[ORM\Entity(repositoryClassClientRepository::class)]
  9. class Client
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     #[Groups(["getClient""getProject""getContact""getReservation"])]
  15.     private ?int $id null;
  16.     #[ORM\Column(length45)]
  17.     #[Groups(["getClient""getProject""getContact""getReservation""getTimes"])]
  18.     private ?string $name null;
  19.     #[ORM\Column]
  20.     #[Groups(["getClient"])]
  21.     private ?bool $active null;
  22.     #[ORM\Column(length6)]
  23.     #[Groups(["getTimes""getClient""getProject""getContact"])]
  24.     private ?string $color null;
  25.     #[ORM\ManyToMany(targetEntityUser::class, mappedBy'clients')]
  26.     private Collection $users;
  27.     #[ORM\OneToMany(mappedBy'client'targetEntityProject::class)]
  28.     #[Groups(["getClient"])]
  29.     private Collection $projects;
  30.     #[ORM\OneToMany(mappedBy'client'targetEntityContact::class)]
  31.     private Collection $contacts;
  32.     #[ORM\OneToMany(mappedBy'client'targetEntityClosureClient::class)]
  33.     private Collection $closuresClient;
  34.     public function __construct()
  35.     {
  36.         $this->users = new ArrayCollection();
  37.         $this->projects = new ArrayCollection();
  38.         $this->contacts = new ArrayCollection();
  39.         $this->closuresClient = new ArrayCollection();
  40.     }
  41.     public function __toString(): string
  42.     {
  43.         return $this->name;
  44.     }
  45.     public function getId(): ?int
  46.     {
  47.         return $this->id;
  48.     }
  49.     public function getName(): ?string
  50.     {
  51.         return $this->name;
  52.     }
  53.     public function setName(string $name): self
  54.     {
  55.         $this->name $name;
  56.         return $this;
  57.     }
  58.     public function setActive(bool $active): self
  59.     {
  60.         $this->active $active;
  61.         return $this;
  62.     }
  63.     public function getColor(): ?string
  64.     {
  65.         return $this->color;
  66.     }
  67.     public function setColor(?string $color): void
  68.     {
  69.         $this->color $color;
  70.     }
  71.     /**
  72.      * @return Collection<int, User>
  73.      */
  74.     public function getUsers(): Collection
  75.     {
  76.         return $this->users;
  77.     }
  78.     public function removeUser(User $user): self
  79.     {
  80.         if ($this->users->removeElement($user)) {
  81.             $user->removeClient($this);
  82.         }
  83.         return $this;
  84.     }
  85.     public function addUser(User $user): self
  86.     {
  87.         if (!$this->users->contains($user)) {
  88.             $this->users->add($user);
  89.             $user->addClient($this);
  90.         }
  91.         return $this;
  92.     }
  93.     /**
  94.      * @return Collection<int, Project>
  95.      */
  96.     public function getProjects(): Collection
  97.     {
  98.         return $this->projects;
  99.     }
  100.     public function isActive(): ?bool
  101.     {
  102.         return $this->active;
  103.     }
  104.     public function addProject(Project $project): self
  105.     {
  106.         if (!$this->projects->contains($project)) {
  107.             $this->projects->add($project);
  108.             $project->setClient($this);
  109.         }
  110.         return $this;
  111.     }
  112.     public function removeProject(Project $project): self
  113.     {
  114.         if ($this->projects->removeElement($project)) {
  115.             if ($project->getClient() === $this) {
  116.                 $project->setClient(null);
  117.             }
  118.         }
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return Collection<int, Contact>
  123.      */
  124.     public function getContacts(): Collection
  125.     {
  126.         return $this->contacts;
  127.     }
  128.     public function addContact(Contact $contact): self
  129.     {
  130.         if (!$this->contacts->contains($contact)) {
  131.             $this->contacts->add($contact);
  132.             $contact->setClient($this);
  133.         }
  134.         return $this;
  135.     }
  136.     public function removeContact(Contact $contact): self
  137.     {
  138.         if ($this->contacts->removeElement($contact)) {
  139.             // set the owning side to null (unless already changed)
  140.             if ($contact->getClient() === $this) {
  141.                 $contact->setClient(null);
  142.             }
  143.         }
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return Collection<int, ClosureClient>
  148.      */
  149.     public function getClosuresClient(): Collection
  150.     {
  151.         return $this->closuresClient;
  152.     }
  153.     public function addClosuresClient(ClosureClient $closuresClient): self
  154.     {
  155.         if (!$this->closuresClient->contains($closuresClient)) {
  156.             $this->closuresClient->add($closuresClient);
  157.             $closuresClient->setClient($this);
  158.         }
  159.         return $this;
  160.     }
  161.     public function removeClosuresClient(ClosureClient $closuresClient): self
  162.     {
  163.         if ($this->closuresClient->removeElement($closuresClient)) {
  164.             // set the owning side to null (unless already changed)
  165.             if ($closuresClient->getClient() === $this) {
  166.                 $closuresClient->setClient(null);
  167.             }
  168.         }
  169.         return $this;
  170.     }
  171. }