src/Entity/ProhibitedCases.php line 18

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\MainTranslationTrait;
  4. use App\Entity\Translation\ProhibitedCasesTranslation;
  5. use App\Repository\ProhibitedCasesRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Gedmo\Translatable\Translatable;
  11. #[ORM\Table(name'prohibited_cases')]
  12. #[ORM\Entity(repositoryClassProhibitedCasesRepository::class)]
  13. #[Gedmo\TranslationEntity(class: ProhibitedCasesTranslation::class)]
  14. class ProhibitedCases  implements Translatable
  15. {
  16.     use MainTranslationTrait;
  17.     const TRANSLATION_ENTITY ProhibitedCasesTranslation::class;
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column]
  21.     private ?int $id null;
  22.     public function __construct()
  23.     {
  24.         $this->attractions = new ArrayCollection();
  25.     }
  26.     public function getId(): ?int
  27.     {
  28.         return $this->id;
  29.     }
  30.     #[ORM\Column(type'string'nullabletrue)]
  31.     #[Gedmo\Translatable]
  32.     private ?string $title null;
  33.     #[ORM\Column(type'string'nullabletrue)]
  34.     private ?string $image null;
  35.     #[ORM\ManyToMany(targetEntityAttractions::class, mappedBy'prohibitedCases')]
  36.     private $attractions;
  37.     public function __toString(): string
  38.     {
  39.         return $this->title ?? "";
  40.     }
  41.     public function getTitle(): ?string
  42.     {
  43.         return $this->title;
  44.     }
  45.     public function setTitle(?string $title): static
  46.     {
  47.         $this->title $title;
  48.         return $this;
  49.     }
  50.     public function getImage(): ?string
  51.     {
  52.         return $this->image;
  53.     }
  54.     public function setImage(?string $image): static
  55.     {
  56.         $this->image $image;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return Collection<int, Attractions>
  61.      */
  62.     public function getAttractions(): Collection
  63.     {
  64.         return $this->attractions;
  65.     }
  66.     public function addAttraction(Attractions $attraction): static
  67.     {
  68.         if (!$this->attractions->contains($attraction)) {
  69.             $this->attractions->add($attraction);
  70.             $attraction->addProhibitedCase($this);
  71.         }
  72.         return $this;
  73.     }
  74.     public function removeAttraction(Attractions $attraction): static
  75.     {
  76.         if ($this->attractions->removeElement($attraction)) {
  77.             $attraction->removeProhibitedCase($this);
  78.         }
  79.         return $this;
  80.     }
  81. }