src/Entity/Locations.php line 22

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. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. /**
  11.  * @ORM\Entity(repositoryClass=LocationsRepository::class)
  12.  * @ORM\Table(name="locations", uniqueConstraints={
  13.  *      @UniqueConstraint(name="unique_location_in_city", columns={"name", "postcode"})
  14.  *     })
  15.  * @UniqueEntity(
  16.  *       fields={"name", "postcode"},
  17.  *       message="This Location already registered|Location with combination (%s %s) is already registered"
  18.  *  )
  19.  */
  20. class Locations
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      * @Groups({
  27.      *     "project.branches",
  28.      *     "branches.location.base",
  29.      *     "location.core", "location:core",
  30.      *     "partner.selected.project",
  31.      *     "branch.location.base",
  32.      *
  33.      *     "location@core",
  34.      *     "location@base"
  35.      * })
  36.      */
  37.     private $id;
  38.     /**
  39.      * @ORM\Column(type="string", length=255)
  40.      * @Groups({
  41.      *     "project.branches",
  42.      *     "branches.location.base",
  43.      *     "location.core", "location:core",
  44.      *     "partner.selected.project",
  45.      *     "branch.location.base",
  46.      *
  47.      *
  48.      *     "location@core",
  49.      *     "location@base"
  50.      *  })
  51.      */
  52.     private $name;
  53.     /**
  54.      * @ORM\Column(type="string", length=255, nullable=true)
  55.      * @Groups({
  56.      *     "project.branches",
  57.      *     "location.core", "location:core",
  58.      *
  59.      *     "location@core"
  60.      * })
  61.      */
  62.     private $street;
  63.     /**
  64.      * @ORM\Column(type="string", length=25, nullable=true)
  65.      * @Groups({
  66.      *     "project.branches",
  67.      *     "branch.location.base",
  68.      *     "location.core", "location:core",
  69.      *
  70.      *     "location@core"
  71.      * })
  72.      */
  73.     private $postcode;
  74.     /**
  75.      * @ORM\Column(type="string", length=64, nullable=true)
  76.      * @Groups({
  77.      *     "project.branches",
  78.      *     "branch.location.base",
  79.      *     "location.core", "location:core",
  80.      *
  81.      *
  82.      *      "location@core"
  83.      * })
  84.      */
  85.     private $city;
  86.     /**
  87.      * @ORM\ManyToOne(targetEntity=Countries::class)
  88.      * @Groups({
  89.      *     "project.branches",
  90.      *     "branch.location.base",
  91.      *     "location.country",
  92.      *
  93.      *     "location@country"
  94.      * })
  95.      */
  96.     private $country;
  97.     /**
  98.      * @ORM\Column(type="string", length=255, nullable=true)
  99.      * @Groups({
  100.      *     "project.branches",
  101.      *     "branch.location.base",
  102.      *     "location.core", "location:core",
  103.      *
  104.      *     "location@core"
  105.      * })
  106.      */
  107.     private $latitude;
  108.     /**
  109.      * @ORM\Column(type="string", length=255, nullable=true)
  110.      * @Groups({
  111.      *     "project.branches",
  112.      *     "branch.location.base",
  113.      *     "location.core", "location:core",
  114.      *
  115.      *     "location@core"
  116.      * })
  117.      */
  118.     private $longitude;
  119.     /**
  120.      * @ORM\Column(type="integer", nullable=true)
  121.      * @Groups({
  122.      *     "project.branches",
  123.      *     "branch.location.base",
  124.      *     "location.core", "location:core",
  125.      *
  126.      *     "location@core"
  127.      * })
  128.      */
  129.     private $scan_distance;
  130.     /**
  131.      * @ORM\OneToMany(targetEntity=Branches::class, mappedBy="branch_location")
  132.      */
  133.     private $branches;
  134.     /**
  135.      * @ORM\OneToMany(targetEntity=Stocks::class, mappedBy="location")
  136.      */
  137.     private $stocks;
  138.     /**
  139.      * @ORM\OneToMany(targetEntity=Warehouses::class, mappedBy="location")
  140.      */
  141.     private $warehouses;
  142.     /**
  143.      * @ORM\Column(type="datetime_immutable", nullable=true)
  144.      */
  145.     private $created_at;
  146.     /**
  147.      * @ORM\OneToMany(targetEntity=Suppliers::class, mappedBy="location")
  148.      */
  149.     private $suppliers;
  150.     public function __construct()
  151.     {
  152.         $this->branches = new ArrayCollection();
  153.         $this->stocks = new ArrayCollection();
  154.         $this->warehouses = new ArrayCollection();
  155.         $this->suppliers = new ArrayCollection();
  156.     }
  157.     public function getId(): ?int
  158.     {
  159.         return $this->id;
  160.     }
  161.     public function getName(): ?string
  162.     {
  163.         return $this->name;
  164.     }
  165.     public function setName(string $name): self
  166.     {
  167.         $this->name $name;
  168.         return $this;
  169.     }
  170.     public function getStreet(): ?string
  171.     {
  172.         return $this->street;
  173.     }
  174.     public function setStreet(?string $street): self
  175.     {
  176.         $this->street $street;
  177.         return $this;
  178.     }
  179.     public function getPostcode(): ?string
  180.     {
  181.         return $this->postcode;
  182.     }
  183.     public function setPostcode(?string $postcode): self
  184.     {
  185.         $this->postcode $postcode;
  186.         return $this;
  187.     }
  188.     public function getCity(): ?string
  189.     {
  190.         return $this->city;
  191.     }
  192.     public function setCity(?string $city): self
  193.     {
  194.         $this->city $city;
  195.         return $this;
  196.     }
  197.     public function getCountry(): ?Countries
  198.     {
  199.         return $this->country;
  200.     }
  201.     public function setCountry(?Countries $country): self
  202.     {
  203.         $this->country $country;
  204.         return $this;
  205.     }
  206.     public function getLatitude(): ?string
  207.     {
  208.         return $this->latitude;
  209.     }
  210.     public function setLatitude(?string $latitude): self
  211.     {
  212.         $this->latitude $latitude;
  213.         return $this;
  214.     }
  215.     public function getLongitude(): ?string
  216.     {
  217.         return $this->longitude;
  218.     }
  219.     public function setLongitude(?string $longitude): self
  220.     {
  221.         $this->longitude $longitude;
  222.         return $this;
  223.     }
  224.     public function getScanDistance(): ?int
  225.     {
  226.         return $this->scan_distance;
  227.     }
  228.     public function setScanDistance(?int $scan_distance): self
  229.     {
  230.         $this->scan_distance $scan_distance;
  231.         return $this;
  232.     }
  233.     /**
  234.      * @return Collection<int, Branches>
  235.      */
  236.     public function getBranches(): Collection
  237.     {
  238.         return $this->branches;
  239.     }
  240.     public function addBranch(Branches $branch): self
  241.     {
  242.         if (!$this->branches->contains($branch)) {
  243.             $this->branches[] = $branch;
  244.             $branch->setBranchLocation($this);
  245.         }
  246.         return $this;
  247.     }
  248.     public function removeBranch(Branches $branch): self
  249.     {
  250.         if ($this->branches->removeElement($branch)) {
  251.             // set the owning side to null (unless already changed)
  252.             if ($branch->getBranchLocation() === $this) {
  253.                 $branch->setBranchLocation(null);
  254.             }
  255.         }
  256.         return $this;
  257.     }
  258.     /**
  259.      * @return Collection<int, Stocks>
  260.      */
  261.     public function getStocks(): Collection
  262.     {
  263.         return $this->stocks;
  264.     }
  265.     public function addStock(Stocks $stock): self
  266.     {
  267.         if (!$this->stocks->contains($stock)) {
  268.             $this->stocks[] = $stock;
  269.             $stock->setLocation($this);
  270.         }
  271.         return $this;
  272.     }
  273.     public function removeStock(Stocks $stock): self
  274.     {
  275.         if ($this->stocks->removeElement($stock)) {
  276.             // set the owning side to null (unless already changed)
  277.             if ($stock->getLocation() === $this) {
  278.                 $stock->setLocation(null);
  279.             }
  280.         }
  281.         return $this;
  282.     }
  283.     /**
  284.      * @return Collection<int, Warehouses>
  285.      */
  286.     public function getWarehouses(): Collection
  287.     {
  288.         return $this->warehouses;
  289.     }
  290.     public function addWarehouse(Warehouses $warehouse): self
  291.     {
  292.         if (!$this->warehouses->contains($warehouse)) {
  293.             $this->warehouses[] = $warehouse;
  294.             $warehouse->setLocation($this);
  295.         }
  296.         return $this;
  297.     }
  298.     public function removeWarehouse(Warehouses $warehouse): self
  299.     {
  300.         if ($this->warehouses->removeElement($warehouse)) {
  301.             // set the owning side to null (unless already changed)
  302.             if ($warehouse->getLocation() === $this) {
  303.                 $warehouse->setLocation(null);
  304.             }
  305.         }
  306.         return $this;
  307.     }
  308.     public function getCreatedAt(): ?\DateTimeImmutable
  309.     {
  310.         return $this->created_at;
  311.     }
  312.     public function setCreatedAt(?\DateTimeImmutable $created_at): self
  313.     {
  314.         $this->created_at $created_at;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return Collection<int, Suppliers>
  319.      */
  320.     public function getSuppliers(): Collection
  321.     {
  322.         return $this->suppliers;
  323.     }
  324.     public function addSupplier(Suppliers $supplier): self
  325.     {
  326.         if (!$this->suppliers->contains($supplier)) {
  327.             $this->suppliers[] = $supplier;
  328.             $supplier->setLocation($this);
  329.         }
  330.         return $this;
  331.     }
  332.     public function removeSupplier(Suppliers $supplier): self
  333.     {
  334.         if ($this->suppliers->removeElement($supplier)) {
  335.             // set the owning side to null (unless already changed)
  336.             if ($supplier->getLocation() === $this) {
  337.                 $supplier->setLocation(null);
  338.             }
  339.         }
  340.         return $this;
  341.     }
  342. }