src/Entity/Academy.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Repository\AcademyRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. #[ORM\Entity(repositoryClassAcademyRepository::class)]
  10. #[ApiResource()]
  11. class Academy
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     #[Groups(['user:read'])]
  17.     private $id;
  18.     #[ORM\Column(type'string'length120)]
  19.     #[Groups(['user:read'])]
  20.     private $label;
  21.     #[ORM\OneToMany(mappedBy'academy'targetEntityUser::class)]
  22.     private $users;
  23.     #[ORM\Column(type'integer'nullabletrue)]
  24.     #[Groups(['user:read'])]
  25.     private $montant;
  26.     #[ORM\Column(type'integer'nullabletrue)]
  27.     #[Groups(['user:read'])]
  28.     private $dateLimited;
  29.     #[ORM\OneToMany(mappedBy'academy'targetEntityPitchDisponibility::class, cascade:['persist','remove'])]
  30.     private $pitchDisponibilities;
  31.     #[ORM\ManyToOne(targetEntityPitch::class, inversedBy'academies')]
  32.     private $pitch;
  33.     public function __construct()
  34.     {
  35.         $this->users = new ArrayCollection();
  36.         $this->pitchDisponibilities = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getLabel(): ?string
  43.     {
  44.         return $this->label;
  45.     }
  46.     public function setLabel(string $label): self
  47.     {
  48.         $this->label $label;
  49.         return $this;
  50.     }
  51.     /**
  52.      * @return Collection<int, User>
  53.      */
  54.     public function getUsers(): Collection
  55.     {
  56.         return $this->users;
  57.     }
  58.     public function addUser(User $user): self
  59.     {
  60.         if (!$this->users->contains($user)) {
  61.             $this->users[] = $user;
  62.             $user->setAcademy($this);
  63.         }
  64.         return $this;
  65.     }
  66.     public function removeUser(User $user): self
  67.     {
  68.         if ($this->users->removeElement($user)) {
  69.             // set the owning side to null (unless already changed)
  70.             if ($user->getAcademy() === $this) {
  71.                 $user->setAcademy(null);
  72.             }
  73.         }
  74.         return $this;
  75.     }
  76.     public function getMontant(): ?int
  77.     {
  78.         return $this->montant;
  79.     }
  80.     public function setMontant(?int $montant): self
  81.     {
  82.         $this->montant $montant;
  83.         return $this;
  84.     }
  85.     public function getDateLimited(): ?int
  86.     {
  87.         return $this->dateLimited;
  88.     }
  89.     public function setDateLimited(?int $dateLimited): self
  90.     {
  91.         $this->dateLimited $dateLimited;
  92.         return $this;
  93.     }
  94.     /**
  95.      * @return Collection<int, PitchDisponibility>
  96.      */
  97.     public function getPitchDisponibilities(): Collection
  98.     {
  99.         return $this->pitchDisponibilities;
  100.     }
  101.     public function addPitchDisponibility(PitchDisponibility $pitchDisponibility): self
  102.     {
  103.         if (!$this->pitchDisponibilities->contains($pitchDisponibility)) {
  104.             $this->pitchDisponibilities[] = $pitchDisponibility;
  105.             $pitchDisponibility->setAcademy($this);
  106.         }
  107.         return $this;
  108.     }
  109.     public function removePitchDisponibility(PitchDisponibility $pitchDisponibility): self
  110.     {
  111.         if ($this->pitchDisponibilities->removeElement($pitchDisponibility)) {
  112.             // set the owning side to null (unless already changed)
  113.             if ($pitchDisponibility->getAcademy() === $this) {
  114.                 $pitchDisponibility->setAcademy(null);
  115.             }
  116.         }
  117.         return $this;
  118.     }
  119.     public function getPitch(): ?Pitch
  120.     {
  121.         return $this->pitch;
  122.     }
  123.     public function setPitch(?Pitch $pitch): self
  124.     {
  125.         $this->pitch $pitch;
  126.         return $this;
  127.     }
  128. }