<?php
namespace App\Entity;
use App\Repository\UserActiveYearRepository;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: UserActiveYearRepository::class)]
#[ORM\UniqueConstraint(name: 'user_school_unique', columns: ['user_id', 'school_id'])]
class UserActiveYear
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?User $user = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
private ?School $school = null;
#[ORM\ManyToOne]
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[Groups(['getUserActiveYear'])]
private ?SchoolYear $schoolYear = null;
#[ORM\Column]
private ?\DateTimeImmutable $updatedAt = null;
public function __construct()
{
$this->updatedAt = new \DateTimeImmutable();
}
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 getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
return $this;
}
public function getSchoolYear(): ?SchoolYear
{
return $this->schoolYear;
}
public function setSchoolYear(?SchoolYear $schoolYear): static
{
$this->schoolYear = $schoolYear;
$this->updatedAt = new \DateTimeImmutable();
return $this;
}
public function getUpdatedAt(): ?\DateTimeImmutable
{
return $this->updatedAt;
}
}