src/Entity/Location.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LocationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=LocationRepository::class)
  9.  */
  10. class Location
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $name;
  22.     /**
  23.      * @ORM\Column(type="json", nullable=true)
  24.      */
  25.     private $coordinates = [];
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $address;
  30.     /**
  31.      * @ORM\ManyToOne(targetEntity=Client::class, inversedBy="locations")
  32.      */
  33.     private $subdivision;
  34.     /**
  35.      * @ORM\Column(type="boolean", nullable=true, options={"default":false})
  36.      */
  37.     private $removed;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=Field::class, mappedBy="location")
  40.      */
  41.     private $fields;
  42.     public function __construct()
  43.     {
  44.         $this->fields = new ArrayCollection();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getName(): ?string
  51.     {
  52.         return $this->name;
  53.     }
  54.     public function setName(string $name): self
  55.     {
  56.         $this->name $name;
  57.         return $this;
  58.     }
  59.     public function getCoordinates(): ?array
  60.     {
  61.         return $this->coordinates;
  62.     }
  63.     public function setCoordinates(?array $coordinates): self
  64.     {
  65.         $this->coordinates $coordinates;
  66.         return $this;
  67.     }
  68.     public function getAddress(): ?string
  69.     {
  70.         return $this->address;
  71.     }
  72.     public function setAddress(?string $address): self
  73.     {
  74.         $this->address $address;
  75.         return $this;
  76.     }
  77.     public function getSubdivision(): ?Client
  78.     {
  79.         return $this->subdivision;
  80.     }
  81.     public function setSubdivision(?Client $subdivision): self
  82.     {
  83.         $this->subdivision $subdivision;
  84.         return $this;
  85.     }
  86.     public function isRemoved(): ?bool
  87.     {
  88.         return $this->removed;
  89.     }
  90.     public function setRemoved(?bool $removed): self
  91.     {
  92.         $this->removed $removed;
  93.         return $this;
  94.     }
  95.     /**
  96.      * @return Collection<int, Field>
  97.      */
  98.     public function getFields(): Collection
  99.     {
  100.         return $this->fields;
  101.     }
  102.     public function addField(Field $field): self
  103.     {
  104.         if (!$this->fields->contains($field)) {
  105.             $this->fields[] = $field;
  106.             $field->setLocation($this);
  107.         }
  108.         return $this;
  109.     }
  110.     public function removeField(Field $field): self
  111.     {
  112.         if ($this->fields->removeElement($field)) {
  113.             // set the owning side to null (unless already changed)
  114.             if ($field->getLocation() === $this) {
  115.                 $field->setLocation(null);
  116.             }
  117.         }
  118.         return $this;
  119.     }
  120. }