109 lines
2.5 KiB
PHP
109 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;
|
|
|
|
/**
|
|
* Matter
|
|
*
|
|
* @ORM\Entity(repositoryClass="App\Repository\MatterRepository")
|
|
* @ORM\Table(name="matter",uniqueConstraints={@ORM\UniqueConstraint(name="unique01", columns={"year_id","name"})})
|
|
* @UniqueEntity(fields={"year","name"}, message="Cette matière existe dèja")
|
|
*/
|
|
class Matter
|
|
{
|
|
/**
|
|
* @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="matters")
|
|
*/
|
|
private $year;
|
|
|
|
/**
|
|
* @ORM\OneToMany(targetEntity="Assignmentmatter", mappedBy="matter")
|
|
*/
|
|
private $assignmentmatters;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->assignmentmatters = 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|Assignmentmatter[]
|
|
*/
|
|
public function getAssignmentmatters(): Collection
|
|
{
|
|
return $this->assignmentmatters;
|
|
}
|
|
|
|
public function addAssignmentmatter(Assignmentmatter $assignmentmatter): self
|
|
{
|
|
if (!$this->assignmentmatters->contains($assignmentmatter)) {
|
|
$this->assignmentmatters[] = $assignmentmatter;
|
|
$assignmentmatter->setMatter($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->getMatter() === $this) {
|
|
$assignmentmatter->setMatter(null);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
|
|
} |