<?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\Column(type: 'string', length: 255)]
private $information;
#[ORM\OneToMany(mappedBy: 'category', targetEntity: CatImage::class)]
private $images;
public function __construct()
{
$this->images = 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;
}
public function getInformation(): ?string
{
return $this->information;
}
public function setInformation(string $information): self
{
$this->information = $information;
return $this;
}
/**
* @return Collection<int, CatImage>
*/
public function getImages(): Collection
{
return $this->images;
}
public function addImage(CatImage $image): self
{
if (!$this->images->contains($image)) {
$this->images[] = $image;
$image->setCategory($this);
}
return $this;
}
public function removeImage(CatImage $image): self
{
if ($this->images->removeElement($image)) {
// set the owning side to null (unless already changed)
if ($image->getCategory() === $this) {
$image->setCategory(null);
}
}
return $this;
}
}