HegreLand/src/Entity/Category.php

86 lines
1.8 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: CategoryRepository::class)]
class Category
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 30)]
private ?string $label = null;
#[ORM\OneToMany(targetEntity: MissionCategory::class, mappedBy: 'category')]
private Collection $missionCategories;
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): static
{
$this->id = $id;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): static
{
$this->label = $label;
return $this;
}
public function getMission(): ?Mission
{
return $this->mission;
}
public function setMission(?Mission $mission): void
{
$this->mission = $mission;
}
public function getMissionCategorie(): Collection
{
return $this->missionCategories;
}
public function addMissionCategory(MissionCategory $missionCategory): static
{
if(!$this->missionCategories->contains($missionCategory)) {
$this->missionCategories->add($missionCategory);
$missionCategory->setCategory($this);
}
return $this;
}
public function removeMissionCategory(MissionCategory $missionCategory): static
{
if($this->missionCategories->removeElement($missionCategory)) {
if($missionCategory->getCategory() === $this) {
$missionCategory->setCategory(null);
}
}
return $this;
}
}