src/Entity/MenuImageCollection.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MenuImageCollectionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassMenuImageCollectionRepository::class)]
  9. class MenuImageCollection
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(typeTypes::SMALLINT)]
  16.     private ?int $ordinal null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $title null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $imageFile null;
  21.     #[ORM\OneToMany(mappedBy'imageCollection'targetEntityMenuImage::class)]
  22.     private Collection $menuImages;
  23.     public function __construct()
  24.     {
  25.         $this->menuImages = new ArrayCollection();
  26.     }
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getOrdinal(): ?int
  32.     {
  33.         return $this->ordinal;
  34.     }
  35.     public function setOrdinal(int $ordinal): static
  36.     {
  37.         $this->ordinal $ordinal;
  38.         return $this;
  39.     }
  40.     public function getTitle(): ?string
  41.     {
  42.         return $this->title;
  43.     }
  44.     public function setTitle(string $title): static
  45.     {
  46.         $this->title $title;
  47.         return $this;
  48.     }
  49.     public function getImageFile(): ?string
  50.     {
  51.         return $this->imageFile;
  52.     }
  53.     public function setImageFile(string $imageFile): static
  54.     {
  55.         $this->imageFile $imageFile;
  56.         return $this;
  57.     }
  58.     /**
  59.      * @return Collection<int, MenuImage>
  60.      */
  61.     public function getMenuImages(): Collection
  62.     {
  63.         return $this->menuImages;
  64.     }
  65.     public function addMenuImage(MenuImage $menuImage): static
  66.     {
  67.         if (!$this->menuImages->contains($menuImage)) {
  68.             $this->menuImages->add($menuImage);
  69.             $menuImage->setImageCollection($this);
  70.         }
  71.         return $this;
  72.     }
  73.     public function removeMenuImage(MenuImage $menuImage): static
  74.     {
  75.         if ($this->menuImages->removeElement($menuImage)) {
  76.             // set the owning side to null (unless already changed)
  77.             if ($menuImage->getImageCollection() === $this) {
  78.                 $menuImage->setImageCollection(null);
  79.             }
  80.         }
  81.         return $this;
  82.     }
  83.     public function __toString(): string
  84.     {
  85.         return $this->getTitle(); // или getId(), или что-то другое
  86.     }
  87. }