<?php
namespace App\Entity;
use App\Repository\ClassYearRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ClassYearRepository::class)]
class ClassYear
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'classYears')]
#[ORM\JoinColumn(nullable: false)]
private ?TheClass $class = null;
#[ORM\ManyToOne(inversedBy: 'classes')]
#[ORM\JoinColumn(nullable: false)]
private ?Chat $chat = null;
#[ORM\ManyToMany(targetEntity: Chat::class, mappedBy: 'classes')]
private Collection $chats;
#[ORM\ManyToOne(inversedBy: 'classYears')]
private ?User $author = null;
#[ORM\ManyToOne(inversedBy: 'ClassYearsEdited')]
private ?User $editor = null;
public function __construct()
{
$this->chats = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getClass(): ?TheClass
{
return $this->class;
}
public function setClass(?TheClass $class): static
{
$this->class = $class;
return $this;
}
/**
* @return Collection<int, Chat>
*/
public function getChats(): Collection
{
return $this->chats;
}
public function addChat(Chat $chat): static
{
if (!$this->chats->contains($chat)) {
$this->chats->add($chat);
$chat->addClass($this);
}
return $this;
}
public function removeChat(Chat $chat): static
{
if ($this->chats->removeElement($chat)) {
$chat->removeClass($this);
}
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
public function getEditor(): ?User
{
return $this->editor;
}
public function setEditor(?User $editor): static
{
$this->editor = $editor;
return $this;
}
}