src/Entity/Etablissement.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\EtablissementRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassEtablissementRepository::class)]
  9. #[ApiResource]
  10. class Etablissement
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $name null;
  18.     #[ORM\Column(length500nullabletrue)]
  19.     private ?string $url null;
  20.     #[ORM\OneToMany(mappedBy'etablissement'targetEntityUser::class)]
  21.     private Collection $users;
  22.     #[ORM\OneToMany(mappedBy'etablissement'targetEntityCompteRendu::class)]
  23.     private Collection $compteRendus;
  24.     public function __toString()
  25.                    {
  26.                        return $this->name;
  27.                    }
  28.     public function __construct()
  29.                    {
  30.                        $this->users = new ArrayCollection();
  31.                        $this->compteRendus = new ArrayCollection();
  32.                    }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(?string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getUrl(): ?string
  47.     {
  48.         return $this->url;
  49.     }
  50.     public function setUrl(?string $url): self
  51.     {
  52.         $this->url $url;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return Collection<int, User>
  57.      */
  58.     public function getUsers(): Collection
  59.     {
  60.         return $this->users;
  61.     }
  62.     public function addUser(User $user): self
  63.     {
  64.         if (!$this->users->contains($user)) {
  65.             $this->users->add($user);
  66.             $user->setEtablissement($this);
  67.         }
  68.         return $this;
  69.     }
  70.     public function removeUser(User $user): self
  71.     {
  72.         if ($this->users->removeElement($user)) {
  73.             // set the owning side to null (unless already changed)
  74.             if ($user->getEtablissement() === $this) {
  75.                 $user->setEtablissement(null);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80.     /**
  81.      * @return Collection<int, CompteRendu>
  82.      */
  83.     public function getCompteRendus(): Collection
  84.     {
  85.         return $this->compteRendus;
  86.     }
  87.     public function addCompteRendu(CompteRendu $compteRendu): self
  88.     {
  89.         if (!$this->compteRendus->contains($compteRendu)) {
  90.             $this->compteRendus->add($compteRendu);
  91.             $compteRendu->setEtablissement($this);
  92.         }
  93.         return $this;
  94.     }
  95.     public function removeCompteRendu(CompteRendu $compteRendu): self
  96.     {
  97.         if ($this->compteRendus->removeElement($compteRendu)) {
  98.             // set the owning side to null (unless already changed)
  99.             if ($compteRendu->getEtablissement() === $this) {
  100.                 $compteRendu->setEtablissement(null);
  101.             }
  102.         }
  103.         return $this;
  104.     }
  105. }