<?php
namespace App\Entity;
use App\Repository\LocationsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping\UniqueConstraint;
/**
* @ORM\Entity(repositoryClass=LocationsRepository::class)
* @ORM\Table(name="locations", uniqueConstraints={
* @UniqueConstraint(name="unique_location_in_city", columns={"name", "postcode"})
* })
*/
class Locations
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "project.branches",
* "branches.location.base",
* "location.core", "location:core", "location@core"
* , "customer.selected.project", "branch.location.base"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "project.branches",
* "branches.location.base",
* "location.core", "location:core", "location@core",
* "customer.selected.project",
* "branch.location.base"
* })
*/
private $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "project.branches",
* "location.core", "location:core", "location@core"
* })
*/
private $street;
/**
* @ORM\Column(type="string", length=25, nullable=true)
* @Groups({
* "project.branches",
* "branch.location.base",
* "location.core", "location:core", "location@core"
* })
*/
private $postcode;
/**
* @ORM\Column(type="string", length=64, nullable=true)
* @Groups({
* "project.branches",
* "branch.location.base",
* "location.core", "location:core", "location@core"
* })
*/
private $city;
/**
* @ORM\ManyToOne(targetEntity=Countries::class)
* @Groups({
* "project.branches",
* "branch.location.base",
* "location.country"
* })
*/
private $country;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "project.branches",
* "branch.location.base",
* "location.core", "location:core", "location@core"
* })
*/
private $latitude;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({
* "project.branches",
* "branch.location.base",
* "location.core", "location:core", "location@core"
* })
*/
private $longitude;
/**
* @ORM\Column(type="integer", nullable=true)
* @Groups({
* "project.branches",
* "branch.location.base",
* "location.core", "location:core", "location@core"
* })
*/
private $scan_distance;
/**
* @ORM\OneToMany(targetEntity=Branches::class, mappedBy="branch_location")
*/
private $branches;
/**
* @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="location")
*/
private $stocks;
/**
* @ORM\OneToMany(targetEntity=Warehouses::class, mappedBy="location")
*/
private $warehouses;
public function __construct()
{
$this->branches = new ArrayCollection();
$this->stocks = new ArrayCollection();
$this->warehouses = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getStreet(): ?string
{
return $this->street;
}
public function setStreet(?string $street): self
{
$this->street = $street;
return $this;
}
public function getPostcode(): ?string
{
return $this->postcode;
}
public function setPostcode(?string $postcode): self
{
$this->postcode = $postcode;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getCountry(): ?Countries
{
return $this->country;
}
public function setCountry(?Countries $country): self
{
$this->country = $country;
return $this;
}
public function getLatitude(): ?string
{
return $this->latitude;
}
public function setLatitude(?string $latitude): self
{
$this->latitude = $latitude;
return $this;
}
public function getLongitude(): ?string
{
return $this->longitude;
}
public function setLongitude(?string $longitude): self
{
$this->longitude = $longitude;
return $this;
}
public function getScanDistance(): ?int
{
return $this->scan_distance;
}
public function setScanDistance(?int $scan_distance): self
{
$this->scan_distance = $scan_distance;
return $this;
}
/**
* @return Collection<int, Branches>
*/
public function getBranches(): Collection
{
return $this->branches;
}
public function addBranch(Branches $branch): self
{
if (!$this->branches->contains($branch)) {
$this->branches[] = $branch;
$branch->setBranchLocation($this);
}
return $this;
}
public function removeBranch(Branches $branch): self
{
if ($this->branches->removeElement($branch)) {
// set the owning side to null (unless already changed)
if ($branch->getBranchLocation() === $this) {
$branch->setBranchLocation(null);
}
}
return $this;
}
/**
* @return Collection<int, Stocks>
*/
public function getStocks(): Collection
{
return $this->stocks;
}
public function addStock(Stocks $stock): self
{
if (!$this->stocks->contains($stock)) {
$this->stocks[] = $stock;
$stock->setLocation($this);
}
return $this;
}
public function removeStock(Stocks $stock): self
{
if ($this->stocks->removeElement($stock)) {
// set the owning side to null (unless already changed)
if ($stock->getLocation() === $this) {
$stock->setLocation(null);
}
}
return $this;
}
/**
* @return Collection<int, Warehouses>
*/
public function getWarehouses(): Collection
{
return $this->warehouses;
}
public function addWarehouse(Warehouses $warehouse): self
{
if (!$this->warehouses->contains($warehouse)) {
$this->warehouses[] = $warehouse;
$warehouse->setLocation($this);
}
return $this;
}
public function removeWarehouse(Warehouses $warehouse): self
{
if ($this->warehouses->removeElement($warehouse)) {
// set the owning side to null (unless already changed)
if ($warehouse->getLocation() === $this) {
$warehouse->setLocation(null);
}
}
return $this;
}
}