src/Entity/ClassYear.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ClassYearRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassClassYearRepository::class)]
  8. class ClassYear
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\ManyToOne(inversedBy'classYears')]
  15.     #[ORM\JoinColumn(nullablefalse)]
  16.     private ?TheClass $class null;
  17.     #[ORM\ManyToOne(inversedBy'classes')]
  18.     #[ORM\JoinColumn(nullablefalse)]
  19.     private ?Chat $chat null;
  20.     #[ORM\ManyToMany(targetEntityChat::class, mappedBy'classes')]
  21.     private Collection $chats;
  22.     #[ORM\ManyToOne(inversedBy'classYears')]
  23.     private ?User $author null;
  24.     #[ORM\ManyToOne(inversedBy'ClassYearsEdited')]
  25.     private ?User $editor null;
  26.     public function __construct()
  27.     {
  28.         $this->chats = new ArrayCollection();
  29.     }
  30.     public function getId(): ?int
  31.     {
  32.         return $this->id;
  33.     }
  34.     public function getClass(): ?TheClass
  35.     {
  36.         return $this->class;
  37.     }
  38.     public function setClass(?TheClass $class): static
  39.     {
  40.         $this->class $class;
  41.         return $this;
  42.     }
  43.     /**
  44.      * @return Collection<int, Chat>
  45.      */
  46.     public function getChats(): Collection
  47.     {
  48.         return $this->chats;
  49.     }
  50.     public function addChat(Chat $chat): static
  51.     {
  52.         if (!$this->chats->contains($chat)) {
  53.             $this->chats->add($chat);
  54.             $chat->addClass($this);
  55.         }
  56.         return $this;
  57.     }
  58.     public function removeChat(Chat $chat): static
  59.     {
  60.         if ($this->chats->removeElement($chat)) {
  61.             $chat->removeClass($this);
  62.         }
  63.         return $this;
  64.     }
  65.     public function getAuthor(): ?User
  66.     {
  67.         return $this->author;
  68.     }
  69.     public function setAuthor(?User $author): static
  70.     {
  71.         $this->author $author;
  72.         return $this;
  73.     }
  74.     public function getEditor(): ?User
  75.     {
  76.         return $this->editor;
  77.     }
  78.     public function setEditor(?User $editor): static
  79.     {
  80.         $this->editor $editor;
  81.         return $this;
  82.     }
  83. }