src/Entity/University.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UniversityRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassUniversityRepository::class)]
  8. class University
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length255)]
  15.     private $name;
  16.     #[ORM\Column(type'string'length255)]
  17.     private $address;
  18.     #[ORM\OneToMany(targetEntityUser::class, mappedBy'university')]
  19.     private $users;
  20.     #[ORM\ManyToMany(targetEntityAccreditation::class)]
  21.     private $accreditation;
  22.     public function __construct()
  23.     {
  24.         $this->users = new ArrayCollection();
  25.         $this->accreditation = new ArrayCollection();
  26.     }
  27.     public function __toString()
  28.     {
  29.         return $this->name;
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getName(): ?string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function setName(string $name): self
  40.     {
  41.         $this->name $name;
  42.         return $this;
  43.     }
  44.     public function getAddress(): ?string
  45.     {
  46.         return $this->address;
  47.     }
  48.     public function setAddress(string $address): self
  49.     {
  50.         $this->address $address;
  51.         return $this;
  52.     }
  53.     /**
  54.      * @return Collection|User[]
  55.      */
  56.     public function getUsers(): Collection
  57.     {
  58.         return $this->users;
  59.     }
  60.     public function addUser(User $user): self
  61.     {
  62.         if (!$this->users->contains($user)) {
  63.             $this->users[] = $user;
  64.             $user->setUniversity($this);
  65.         }
  66.         return $this;
  67.     }
  68.     public function removeUser(User $user): self
  69.     {
  70.         if ($this->users->removeElement($user)) {
  71.             // set the owning side to null (unless already changed)
  72.             if ($user->getUniversity() === $this) {
  73.                 $user->setUniversity(null);
  74.             }
  75.         }
  76.         return $this;
  77.     }
  78.     /**
  79.      * @return Collection|Accreditation[]
  80.      */
  81.     public function getAccreditation(): Collection
  82.     {
  83.         return $this->accreditation;
  84.     }
  85.     public function addAccreditation(Accreditation $accreditation): self
  86.     {
  87.         if (!$this->accreditation->contains($accreditation)) {
  88.             $this->accreditation[] = $accreditation;
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeAccreditation(Accreditation $accreditation): self
  93.     {
  94.         $this->accreditation->removeElement($accreditation);
  95.         return $this;
  96.     }
  97. }