220 lines
5.5 KiB
PHP
220 lines
5.5 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
|
|
/**
|
|
* Classroom
|
|
*
|
|
* @ORM\Entity(repositoryClass="App\Repository\ClassroomRepository")
|
|
* @ORM\Table(name="classroom",uniqueConstraints={@ORM\UniqueConstraint(name="unique01", columns={"year_id","name"})})
|
|
* @UniqueEntity(fields={"year","name"}, message="Cette classe existe dèja")
|
|
*/
|
|
class Classroom
|
|
{
|
|
/**
|
|
* @ORM\Column(name="id", type="integer")
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\Column(name="name", type="string")
|
|
*
|
|
*/
|
|
private $name;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Year", inversedBy="classrooms")
|
|
*/
|
|
private $year;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Student", mappedBy="classroom")
|
|
*/
|
|
private $students;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Assignmentteacher", mappedBy="classroom")
|
|
*/
|
|
private $assignmentteachers;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Assignmentmatter", mappedBy="classroom")
|
|
*/
|
|
private $assignmentmatters;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Assignment", mappedBy="classroom")
|
|
*/
|
|
private $assignments;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->students = new ArrayCollection();
|
|
$this->assignmentteachers = new ArrayCollection();
|
|
$this->assignmentmatters = new ArrayCollection();
|
|
$this->assignments = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): ?string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): self
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getYear(): ?Year
|
|
{
|
|
return $this->year;
|
|
}
|
|
|
|
public function setYear(?Year $year): self
|
|
{
|
|
$this->year = $year;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Student[]
|
|
*/
|
|
public function getStudents(): Collection
|
|
{
|
|
return $this->students;
|
|
}
|
|
|
|
public function addStudent(Student $student): self
|
|
{
|
|
if (!$this->students->contains($student)) {
|
|
$this->students[] = $student;
|
|
$student->setClassroom($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeStudent(Student $student): self
|
|
{
|
|
if ($this->students->contains($student)) {
|
|
$this->students->removeElement($student);
|
|
// set the owning side to null (unless already changed)
|
|
if ($student->getClassroom() === $this) {
|
|
$student->setClassroom(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Assignmentteacher[]
|
|
*/
|
|
public function getAssignmentteachers(): Collection
|
|
{
|
|
return $this->assignmentteachers;
|
|
}
|
|
|
|
public function addAssignmentteacher(Assignmentteacher $assignmentteacher): self
|
|
{
|
|
if (!$this->assignmentteachers->contains($assignmentteacher)) {
|
|
$this->assignmentteachers[] = $assignmentteacher;
|
|
$assignmentteacher->setClassroom($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeAssignmentteacher(Assignmentteacher $assignmentteacher): self
|
|
{
|
|
if ($this->assignmentteachers->contains($assignmentteacher)) {
|
|
$this->assignmentteachers->removeElement($assignmentteacher);
|
|
// set the owning side to null (unless already changed)
|
|
if ($assignmentteacher->getClassroom() === $this) {
|
|
$assignmentteacher->setClassroom(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Assignmentmatter[]
|
|
*/
|
|
public function getAssignmentmatters(): Collection
|
|
{
|
|
return $this->assignmentmatters;
|
|
}
|
|
|
|
public function addAssignmentmatter(Assignmentmatter $assignmentmatter): self
|
|
{
|
|
if (!$this->assignmentmatters->contains($assignmentmatter)) {
|
|
$this->assignmentmatters[] = $assignmentmatter;
|
|
$assignmentmatter->setClassroom($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeAssignmentmatter(Assignmentmatter $assignmentmatter): self
|
|
{
|
|
if ($this->assignmentmatters->contains($assignmentmatter)) {
|
|
$this->assignmentmatters->removeElement($assignmentmatter);
|
|
// set the owning side to null (unless already changed)
|
|
if ($assignmentmatter->getClassroom() === $this) {
|
|
$assignmentmatter->setClassroom(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Assignment[]
|
|
*/
|
|
public function getAssignments(): Collection
|
|
{
|
|
return $this->assignments;
|
|
}
|
|
|
|
public function addAssignment(Assignment $assignment): self
|
|
{
|
|
if (!$this->assignments->contains($assignment)) {
|
|
$this->assignments[] = $assignment;
|
|
$assignment->setClassroom($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeAssignment(Assignment $assignment): self
|
|
{
|
|
if ($this->assignments->contains($assignment)) {
|
|
$this->assignments->removeElement($assignment);
|
|
// set the owning side to null (unless already changed)
|
|
if ($assignment->getClassroom() === $this) {
|
|
$assignment->setClassroom(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
|
|
} |