<?php
namespace App\Entity;
use App\Repository\TypeCollectionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: TypeCollectionRepository::class)]
class TypeCollection
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy:'IDENTITY')]
#[ORM\Column(name: 'id_type_collection',type: 'integer', nullable: false)]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $nom = null;
#[ORM\OneToMany(mappedBy: 'typeCollection', targetEntity: Model::class)]
private Collection $models;
#[ORM\ManyToMany(targetEntity: Categorie::class, inversedBy: 'typeCollections')]
#[ORM\JoinTable(name:'typeCollection_categorie')]
#[ORM\JoinColumn(name: 'id_type_collection', referencedColumnName: 'id_type_collection')]
#[ORM\InverseJoinColumn(name: 'id_categorie', referencedColumnName: 'id_categorie')]
private Collection $categories;
#[ORM\OneToMany(mappedBy: 'typeCollection', targetEntity: Matiere::class)]
private Collection $matieres;
#[ORM\OneToMany(mappedBy: 'typeCollection', targetEntity: Forme::class)]
private Collection $formes;
public function __construct()
{
$this->models = new ArrayCollection();
$this->categories = new ArrayCollection();
$this->matieres = new ArrayCollection();
$this->formes = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(string $nom): self
{
$this->nom = $nom;
return $this;
}
/**
* @return Collection<int, Model>
*/
public function getModels(): Collection
{
return $this->models;
}
public function addModel(Model $model): self
{
if (!$this->models->contains($model)) {
$this->models->add($model);
$model->setTypeCollection($this);
}
return $this;
}
public function removeModel(Model $model): self
{
if ($this->models->removeElement($model)) {
// set the owning side to null (unless already changed)
if ($model->getTypeCollection() === $this) {
$model->setTypeCollection(null);
}
}
return $this;
}
/**
* @return Collection<int, Categorie>
*/
public function getCategories(): Collection
{
return $this->categories;
}
public function addCategory(Categorie $category): self
{
if (!$this->categories->contains($category)) {
$this->categories->add($category);
}
return $this;
}
public function removeCategory(Categorie $category): self
{
$this->categories->removeElement($category);
return $this;
}
/**
* @return Collection<int, Matiere>
*/
public function getMatieres(): Collection
{
return $this->matieres;
}
public function addMatiere(Matiere $matiere): self
{
if (!$this->matieres->contains($matiere)) {
$this->matieres->add($matiere);
$matiere->setTypeCollection($this);
}
return $this;
}
public function removeMatiere(Matiere $matiere): self
{
if ($this->matieres->removeElement($matiere)) {
// set the owning side to null (unless already changed)
if ($matiere->getTypeCollection() === $this) {
$matiere->setTypeCollection(null);
}
}
return $this;
}
/**
* @return Collection<int, Forme>
*/
public function getFormes(): Collection
{
return $this->formes;
}
public function addForm(Forme $forme): self
{
if (!$this->formes->contains($forme)) {
$this->formes->add($forme);
$forme->setTypeCollection($this);
}
return $this;
}
public function removeForme(Forme $forme): self
{
if ($this->formes->removeElement($forme)) {
// set the owning side to null (unless already changed)
if ($forme->getTypeCollection() === $this) {
$forme->setTypeCollection(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->nom;
}
}