<?phpnamespace 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=100) */ private $label; /** * @ORM\Column(type="boolean") */ private $is_active; /** * @ORM\ManyToOne(targetEntity=Section::class, inversedBy="categories") * @ORM\JoinColumn(nullable=false) */ private $section; /** * @ORM\OneToMany(targetEntity=Article::class, mappedBy="category", orphanRemoval=true) */ private $articles; public function __construct() { $this->articles = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getLabel(): ?string { return $this->label; } public function setLabel(string $label): self { $this->label = $label; return $this; } public function isIsActive(): ?bool { return $this->is_active; } public function setIsActive(bool $is_active): self { $this->is_active = $is_active; return $this; } /** * @return mixed */ public function getSection() { return $this->section; } /** * @param mixed $section */ public function setSection($section): void { $this->section = $section; } /** * @return Collection<int, Article> */ public function getArticles(): Collection { return $this->articles; } public function addArticle(Article $article): self { if (!$this->articles->contains($article)) { $this->articles[] = $article; $article->setCategory($this); } return $this; } public function removeArticle(Article $article): self { if ($this->articles->removeElement($article)) { // set the owning side to null (unless already changed) if ($article->getCategory() === $this) { $article->setCategory(null); } } return $this; } /** * @return Collection<int, Article> */ public function getMoreArticles(Article $article): Collection { $elements = new ArrayCollection(); foreach ($this->articles as $art){ if ($art != $article){ $elements[] = $art; } } return $elements; }}