src/Entity/Category.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassCategoryRepository::class)]
  8. class Category
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column(type'integer')]
  13.     private $id;
  14.     #[ORM\Column(type'string'length255)]
  15.     private $title;
  16.     #[ORM\Column(type'string'length255)]
  17.     private $information;
  18.     #[ORM\OneToMany(mappedBy'category'targetEntityCatImage::class)]
  19.     private $images;
  20.     public function __construct()
  21.     {
  22.         $this->images = new ArrayCollection();
  23.     }
  24.     public function getId(): ?int
  25.     {
  26.         return $this->id;
  27.     }
  28.     public function getTitle(): ?string
  29.     {
  30.         return $this->title;
  31.     }
  32.     public function setTitle(string $title): self
  33.     {
  34.         $this->title $title;
  35.         return $this;
  36.     }
  37.     public function getInformation(): ?string
  38.     {
  39.         return $this->information;
  40.     }
  41.     public function setInformation(string $information): self
  42.     {
  43.         $this->information $information;
  44.         return $this;
  45.     }
  46.     /**
  47.      * @return Collection<int, CatImage>
  48.      */
  49.     public function getImages(): Collection
  50.     {
  51.         return $this->images;
  52.     }
  53.     public function addImage(CatImage $image): self
  54.     {
  55.         if (!$this->images->contains($image)) {
  56.             $this->images[] = $image;
  57.             $image->setCategory($this);
  58.         }
  59.         return $this;
  60.     }
  61.     public function removeImage(CatImage $image): self
  62.     {
  63.         if ($this->images->removeElement($image)) {
  64.             // set the owning side to null (unless already changed)
  65.             if ($image->getCategory() === $this) {
  66.                 $image->setCategory(null);
  67.             }
  68.         }
  69.         return $this;
  70.     }
  71. }