src/Entity/Location/Location.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Location;
  3. use App\Entity\Tag;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity]
  8. #[ORM\Table(name:"locations")]
  9. class Location
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\Column(type'uuid'uniquetrue)]
  13.     private $id;
  14.     #[ORM\Column(type'string'length255)]
  15.     private $name;
  16.     #[ORM\Column(type'text')]
  17.     private $description;
  18.     #[ORM\Column(type'string'length255nullabletrue)]
  19.     private $short_description;
  20.     #[ORM\Column(type'text')]
  21.     private $hidden_description;
  22.     #[ORM\Column(type'uuid'nullabletrue)]
  23.     private $glued_to;
  24.     #[ORM\Column(type'string'length50)]
  25.     private $type;
  26.     
  27.     #[ORM\ManyToMany(targetEntity'App\Entity\Tag')]
  28.     #[ORM\JoinTable(
  29.         name'location_tags',
  30.         joinColumns: [new ORM\JoinColumn(name'location_id'referencedColumnName'id')],
  31.         inverseJoinColumns: [new ORM\JoinColumn(name'tag_id'referencedColumnName'id')]
  32.     )]
  33.     private Collection $tags;
  34.     
  35.     #[ORM\ManyToOne(targetEntity'App\Entity\World'inversedBy'locations')]
  36.     #[ORM\JoinColumn(nullablefalse)]
  37.     private $world;
  38.     public function __construct(
  39.         string $name,
  40.         string $description,
  41.         string $short_description,
  42.     ) {
  43.         $this->name $name;
  44.         $this->description $description;
  45.         // $this->npcs = new ArrayCollection();
  46.         $this->tags = new ArrayCollection();
  47.         $this->short_description $short_description;
  48.     }
  49.     
  50.     public function getShortDescription(): ?string
  51.     {
  52.         return $this->short_description;
  53.     }
  54.     // Getters and setters
  55.     public function getId(): ?string
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getName(): ?string
  60.     {
  61.         return $this->name;
  62.     }
  63.     public function setName(string $name): self
  64.     {
  65.         $this->name $name;
  66.         return $this;
  67.     }
  68.     public function getDescription(): ?string
  69.     {
  70.         return $this->description;
  71.     }
  72.     public function setShortDescription(?string $shortDescription): self
  73.     {
  74.         $this->short_description $shortDescription;
  75.         return $this;
  76.     }
  77.     public function setDescription(string $description): self
  78.     {
  79.         $this->description $description;
  80.         return $this;
  81.     }
  82.     public function getHiddenDescription(): ?string
  83.     {
  84.         return $this->hidden_description;
  85.     }
  86.     public function setHiddenDescription(string $hidden_description): self
  87.     {
  88.         $this->hidden_description $hidden_description;
  89.         return $this;
  90.     }
  91.     public function getGluedTo(): ?string
  92.     {
  93.         return $this->glued_to;
  94.     }
  95.     public function setGluedTo(?string $glued_to): self
  96.     {
  97.         $this->glued_to $glued_to;
  98.         return $this;
  99.     }
  100.     public function getTags(): Collection
  101.     {
  102.         return $this->tags;
  103.     }
  104.     public function addTag(Tag $tag): void
  105.     {
  106.         if (!$this->tags->contains($tag)) {
  107.             $this->tags->add($tag);
  108.         }
  109.     }
  110. }