src/Entity/AttractionTypes.php line 17

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