<?php
namespace App\Entity;
use App\Repository\CategoryRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CategoryRepository::class)
*/
class Category
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\OneToMany(targetEntity=SousCategory::class, mappedBy="category", orphanRemoval=true)
*/
private $SousCategory;
public function __construct()
{
$this->SousCategory = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection|SousCategory[]
*/
public function getSousCategory(): Collection
{
return $this->SousCategory;
}
public function addSousCategory(SousCategory $sousCategory): self
{
if (!$this->SousCategory->contains($sousCategory)) {
$this->SousCategory[] = $sousCategory;
$sousCategory->setCategory($this);
}
return $this;
}
public function removeSousCategory(SousCategory $sousCategory): self
{
if ($this->SousCategory->removeElement($sousCategory)) {
// set the owning side to null (unless already changed)
if ($sousCategory->getCategory() === $this) {
$sousCategory->setCategory(null);
}
}
return $this;
}
}