src/Entity/TypeEnseignement.php line 20
<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\TypeEnseignementRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: TypeEnseignementRepository::class)]
#[ApiResource(
operations: [
new GetCollection()
]
)]
class TypeEnseignement
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['read:user:item'])]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: "Ne peut ĂȘtre vide !")]
#[Assert\NotNull(message: "Ne peut ĂȘtre nul !")]
#[Groups(['read:user:item'])]
private ?string $name = null;
#[ORM\Column(length: 255)]
#[Groups(['read:user:item'])]
private ?string $slug = null;
#[ORM\OneToMany(mappedBy: 'typeEnseignement', targetEntity: Filiere::class, orphanRemoval: true)]
private Collection $filieres;
public function __construct()
{
$this->filieres = 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 getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
/**
* @return Collection<int, Filiere>
*/
public function getFilieres(): Collection
{
return $this->filieres;
}
public function addFiliere(Filiere $filiere): self
{
if (!$this->filieres->contains($filiere)) {
$this->filieres->add($filiere);
$filiere->setTypeEnseignement($this);
}
return $this;
}
public function removeFiliere(Filiere $filiere): self
{
if ($this->filieres->removeElement($filiere)) {
// set the owning side to null (unless already changed)
if ($filiere->getTypeEnseignement() === $this) {
$filiere->setTypeEnseignement(null);
}
}
return $this;
}
}