src/Entity/TacheAssistant.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\TacheAssistantRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassTacheAssistantRepository::class)]
  9. #[ApiResource]
  10. class TacheAssistant
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $tache null;
  18.     #[ORM\ManyToMany(targetEntityUser::class, mappedBy'taches')]
  19.     private Collection $users;
  20.     public function __construct()
  21.     {
  22.         $this->users = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getTache(): ?string
  29.     {
  30.         return $this->tache;
  31.     }
  32.     public function setTache(?string $tache): self
  33.     {
  34.         $this->tache $tache;
  35.         return $this;
  36.     }
  37.     /**
  38.      * @return Collection<int, User>
  39.      */
  40.     public function getUsers(): Collection
  41.     {
  42.         return $this->users;
  43.     }
  44.     public function addUser(User $user): self
  45.     {
  46.         if (!$this->users->contains($user)) {
  47.             $this->users->add($user);
  48.             $user->addTach($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeUser(User $user): self
  53.     {
  54.         if ($this->users->removeElement($user)) {
  55.             $user->removeTach($this);
  56.         }
  57.         return $this;
  58.     }
  59. }