<?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;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass=LocationsRepository::class)
* @ORM\Table(name="locations", uniqueConstraints={
* @UniqueConstraint(name="unique_location_in_city", columns={"name", "postcode"})
* })
* @UniqueEntity(
* fields={"name", "postcode"},
* message="This Location already registered|Location with combination (%s %s) is already registered"
* )
*/
class Locations
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "project.branches",
* "branches.location.base",
* "location.core", "location:core",
* "partner.selected.project",
* "branch.location.base",
*
* "location@core",
* "location@base"
* })
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "project.branches",
* "branches.location.base",
* "location.core", "location:core",
* "partner.selected.project",
* "branch.location.base",
*
*
* "location@core",
* "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",
*
* "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;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $created_at;
/**
* @ORM\OneToMany(targetEntity=Suppliers::class, mappedBy="location")
*/
private $suppliers;
public function __construct()
{
$this->branches = new ArrayCollection();
$this->stocks = new ArrayCollection();
$this->warehouses = new ArrayCollection();
$this->suppliers = 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;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->created_at;
}
public function setCreatedAt(?\DateTimeImmutable $created_at): self
{
$this->created_at = $created_at;
return $this;
}
/**
* @return Collection<int, Suppliers>
*/
public function getSuppliers(): Collection
{
return $this->suppliers;
}
public function addSupplier(Suppliers $supplier): self
{
if (!$this->suppliers->contains($supplier)) {
$this->suppliers[] = $supplier;
$supplier->setLocation($this);
}
return $this;
}
public function removeSupplier(Suppliers $supplier): self
{
if ($this->suppliers->removeElement($supplier)) {
// set the owning side to null (unless already changed)
if ($supplier->getLocation() === $this) {
$supplier->setLocation(null);
}
}
return $this;
}
}