<?php
namespace App\Entity;
use App\Repository\UserYearRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use App\Entity\Traits\Timestampable;
use JMS\Serializer\Annotation\Groups;
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: UserYearRepository::class)]
class UserYear
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne(inversedBy: 'userYears')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(['chatView', 'chatAllList', 'singleMessage','getAppUsers'])]
private ?User $user = null;
#[ORM\ManyToOne(inversedBy: 'userYears')]
#[ORM\JoinColumn(nullable: false)]
private ?SchoolYear $year = null;
#[ORM\Column(length: 255)]
private ?string $userType = null;
#[ORM\ManyToOne(inversedBy: 'userYears')]
#[Groups(['getAppUsers'])]
private ?School $school = null;
#[ORM\OneToMany(mappedBy: 'principalProf', targetEntity: TheClass::class)]
private Collection $principalClasses;
public function __construct()
{
$this->messages = new ArrayCollection();
$this->principalClasses = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
public function getYear(): ?SchoolYear
{
return $this->year;
}
public function setYear(?SchoolYear $year): static
{
$this->year = $year;
return $this;
}
public function getUserType(): ?string
{
return $this->userType;
}
public function setUserType(string $userType): static
{
$this->userType = $userType;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
return $this;
}
/**
* @return Collection<int, TheClass>
*/
public function getPrincipalClasses(): Collection
{
return $this->principalClasses;
}
public function addPrincipalClass(TheClass $principalClass): static
{
if (!$this->principalClasses->contains($principalClass)) {
$this->principalClasses->add($principalClass);
$principalClass->setPrincipalProf($this);
}
return $this;
}
public function removePrincipalClass(TheClass $principalClass): static
{
if ($this->principalClasses->removeElement($principalClass)) {
// set the owning side to null (unless already changed)
if ($principalClass->getPrincipalProf() === $this) {
$principalClass->setPrincipalProf(null);
}
}
return $this;
}
}