107 lines
2.5 KiB
PHP
107 lines
2.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;
|
|
|
|
/**
|
|
* Report
|
|
*
|
|
* @ORM\Entity(repositoryClass="App\Repository\ReportRepository")
|
|
* @ORM\Table(name="report",uniqueConstraints={@ORM\UniqueConstraint(name="unique01", columns={"student_id","period_id"})})
|
|
* @UniqueEntity(fields={"student","period"}, message="Cette élève a déjà un bulletin pour cette période")
|
|
*/
|
|
class Report
|
|
{
|
|
/**
|
|
* @ORM\Column(name="id", type="integer")
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
private $id;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Period", inversedBy="reports")
|
|
*/
|
|
private $period;
|
|
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Student", inversedBy="reports")
|
|
*/
|
|
private $student;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Reportdetail", mappedBy="report")
|
|
*/
|
|
private $reportdetails;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->reportdetails = new ArrayCollection();
|
|
}
|
|
|
|
public function getId(): ?int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getPeriod(): ?Period
|
|
{
|
|
return $this->period;
|
|
}
|
|
|
|
public function setPeriod(?Period $period): self
|
|
{
|
|
$this->period = $period;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getStudent(): ?Student
|
|
{
|
|
return $this->student;
|
|
}
|
|
|
|
public function setStudent(?Student $student): self
|
|
{
|
|
$this->student = $student;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return Collection|Reportdetail[]
|
|
*/
|
|
public function getReportdetails(): Collection
|
|
{
|
|
return $this->reportdetails;
|
|
}
|
|
|
|
public function addReportdetail(Reportdetail $reportdetail): self
|
|
{
|
|
if (!$this->reportdetails->contains($reportdetail)) {
|
|
$this->reportdetails[] = $reportdetail;
|
|
$reportdetail->setReport($this);
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function removeReportdetail(Reportdetail $reportdetail): self
|
|
{
|
|
if ($this->reportdetails->contains($reportdetail)) {
|
|
$this->reportdetails->removeElement($reportdetail);
|
|
// set the owning side to null (unless already changed)
|
|
if ($reportdetail->getReport() === $this) {
|
|
$reportdetail->setReport(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
} |