src/Entity/Locations.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LocationsRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. use Doctrine\ORM\Mapping\UniqueConstraint;
  9. /**
  10.  * @ORM\Entity(repositoryClass=LocationsRepository::class)
  11.  * @ORM\Table(name="locations", uniqueConstraints={
  12.  *      @UniqueConstraint(name="unique_location_in_city", columns={"name", "postcode"})
  13.  *     })
  14.  */
  15. class Locations
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      * @Groups({
  22.      *     "project.branches",
  23.      *     "branches.location.base",
  24.      *     "location.core", "location:core", "location@core"
  25.      * , "customer.selected.project", "branch.location.base"})
  26.      */
  27.     private $id;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      * @Groups({
  31.      *     "project.branches",
  32.      *     "branches.location.base",
  33.      *     "location.core", "location:core", "location@core",
  34.      *     "customer.selected.project",
  35.      *     "branch.location.base"
  36.      * })
  37.      */
  38.     private $name;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      * @Groups({
  42.      *     "project.branches",
  43.      *     "location.core", "location:core", "location@core"
  44.      * })
  45.      */
  46.     private $street;
  47.     /**
  48.      * @ORM\Column(type="string", length=25, nullable=true)
  49.      * @Groups({
  50.      *     "project.branches",
  51.      *     "branch.location.base",
  52.      *     "location.core", "location:core", "location@core"
  53.      * })
  54.      */
  55.     private $postcode;
  56.     /**
  57.      * @ORM\Column(type="string", length=64, nullable=true)
  58.      * @Groups({
  59.      *     "project.branches",
  60.      *     "branch.location.base",
  61.      *     "location.core", "location:core", "location@core"
  62.      * })
  63.      */
  64.     private $city;
  65.     /**
  66.      * @ORM\ManyToOne(targetEntity=Countries::class)
  67.      * @Groups({
  68.      *     "project.branches",
  69.      *     "branch.location.base",
  70.      *     "location.country"
  71.      * })
  72.      */
  73.     private $country;
  74.     /**
  75.      * @ORM\Column(type="string", length=255, nullable=true)
  76.      * @Groups({
  77.      *     "project.branches",
  78.      *     "branch.location.base",
  79.      *     "location.core", "location:core", "location@core"
  80.      * })
  81.      */
  82.     private $latitude;
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      * @Groups({
  86.      *     "project.branches",
  87.      *     "branch.location.base",
  88.      *     "location.core", "location:core", "location@core"
  89.      * })
  90.      */
  91.     private $longitude;
  92.     /**
  93.      * @ORM\Column(type="integer", nullable=true)
  94.      * @Groups({
  95.      *     "project.branches",
  96.      *     "branch.location.base",
  97.      *     "location.core", "location:core", "location@core"
  98.      * })
  99.      */
  100.     private $scan_distance;
  101.     /**
  102.      * @ORM\OneToMany(targetEntity=Branches::class, mappedBy="branch_location")
  103.      */
  104.     private $branches;
  105.     /**
  106.      * @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="location")
  107.      */
  108.     private $stocks;
  109.     /**
  110.      * @ORM\OneToMany(targetEntity=Warehouses::class, mappedBy="location")
  111.      */
  112.     private $warehouses;
  113.     public function __construct()
  114.     {
  115.         $this->branches = new ArrayCollection();
  116.         $this->stocks = new ArrayCollection();
  117.         $this->warehouses = new ArrayCollection();
  118.     }
  119.     public function getId(): ?int
  120.     {
  121.         return $this->id;
  122.     }
  123.     public function getName(): ?string
  124.     {
  125.         return $this->name;
  126.     }
  127.     public function setName(string $name): self
  128.     {
  129.         $this->name $name;
  130.         return $this;
  131.     }
  132.     public function getStreet(): ?string
  133.     {
  134.         return $this->street;
  135.     }
  136.     public function setStreet(?string $street): self
  137.     {
  138.         $this->street $street;
  139.         return $this;
  140.     }
  141.     public function getPostcode(): ?string
  142.     {
  143.         return $this->postcode;
  144.     }
  145.     public function setPostcode(?string $postcode): self
  146.     {
  147.         $this->postcode $postcode;
  148.         return $this;
  149.     }
  150.     public function getCity(): ?string
  151.     {
  152.         return $this->city;
  153.     }
  154.     public function setCity(?string $city): self
  155.     {
  156.         $this->city $city;
  157.         return $this;
  158.     }
  159.     public function getCountry(): ?Countries
  160.     {
  161.         return $this->country;
  162.     }
  163.     public function setCountry(?Countries $country): self
  164.     {
  165.         $this->country $country;
  166.         return $this;
  167.     }
  168.     public function getLatitude(): ?string
  169.     {
  170.         return $this->latitude;
  171.     }
  172.     public function setLatitude(?string $latitude): self
  173.     {
  174.         $this->latitude $latitude;
  175.         return $this;
  176.     }
  177.     public function getLongitude(): ?string
  178.     {
  179.         return $this->longitude;
  180.     }
  181.     public function setLongitude(?string $longitude): self
  182.     {
  183.         $this->longitude $longitude;
  184.         return $this;
  185.     }
  186.     public function getScanDistance(): ?int
  187.     {
  188.         return $this->scan_distance;
  189.     }
  190.     public function setScanDistance(?int $scan_distance): self
  191.     {
  192.         $this->scan_distance $scan_distance;
  193.         return $this;
  194.     }
  195.     /**
  196.      * @return Collection<int, Branches>
  197.      */
  198.     public function getBranches(): Collection
  199.     {
  200.         return $this->branches;
  201.     }
  202.     public function addBranch(Branches $branch): self
  203.     {
  204.         if (!$this->branches->contains($branch)) {
  205.             $this->branches[] = $branch;
  206.             $branch->setBranchLocation($this);
  207.         }
  208.         return $this;
  209.     }
  210.     public function removeBranch(Branches $branch): self
  211.     {
  212.         if ($this->branches->removeElement($branch)) {
  213.             // set the owning side to null (unless already changed)
  214.             if ($branch->getBranchLocation() === $this) {
  215.                 $branch->setBranchLocation(null);
  216.             }
  217.         }
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, Stocks>
  222.      */
  223.     public function getStocks(): Collection
  224.     {
  225.         return $this->stocks;
  226.     }
  227.     public function addStock(Stocks $stock): self
  228.     {
  229.         if (!$this->stocks->contains($stock)) {
  230.             $this->stocks[] = $stock;
  231.             $stock->setLocation($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeStock(Stocks $stock): self
  236.     {
  237.         if ($this->stocks->removeElement($stock)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($stock->getLocation() === $this) {
  240.                 $stock->setLocation(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, Warehouses>
  247.      */
  248.     public function getWarehouses(): Collection
  249.     {
  250.         return $this->warehouses;
  251.     }
  252.     public function addWarehouse(Warehouses $warehouse): self
  253.     {
  254.         if (!$this->warehouses->contains($warehouse)) {
  255.             $this->warehouses[] = $warehouse;
  256.             $warehouse->setLocation($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeWarehouse(Warehouses $warehouse): self
  261.     {
  262.         if ($this->warehouses->removeElement($warehouse)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($warehouse->getLocation() === $this) {
  265.                 $warehouse->setLocation(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270. }