src/Entity/CompanyLocation.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\CompanyLocationRepository")
  9.  */
  10. class CompanyLocation
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=20)
  20.      */
  21.     private $civicNumber;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $streetName;
  26.     /**
  27.      * @ORM\Column(type="string", length=255)
  28.      * @Groups({"searchable"})
  29.      */
  30.     private $city;
  31.     /**
  32.      * @ORM\Column(type="string", length=10)
  33.      */
  34.     private $zipCode;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $province='QC';
  39.     /**
  40.      * @ORM\Column(type="string", length=255)
  41.      */
  42.     private $country='CA';
  43.     /**
  44.      * @ORM\Column(type="string", length=20)
  45.      */
  46.     private $phone;
  47.     /**
  48.      * @ORM\Column(type="string", length=10, nullable=true)
  49.      */
  50.     private $phoneExtension;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      */
  54.     private $email;
  55.     /**
  56.      * @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="otherLocations")
  57.      * @ORM\JoinColumn(onDelete="CASCADE")
  58.      */
  59.     private $company;
  60.     /**
  61.      * @ORM\Column(type="string", length=255, nullable=true)
  62.      */
  63.     private $mobilePhone;
  64.     /**
  65.      * @ORM\Column(type="string", length=255, nullable=true)
  66.      * @Groups({"searchable"})
  67.      */
  68.     private $name;
  69.     /**
  70.      * @ORM\Column(type="text", nullable=true)
  71.      */
  72.     private $notesForBuyer;
  73.     /**
  74.      * @ORM\Column(type="boolean")
  75.      */
  76.     //@Note if false it mean it's a real building company
  77.     private $pickUp=true;
  78.     /**
  79.      * @ORM\ManyToMany(targetEntity="App\Entity\Product", mappedBy="locations")
  80.      */
  81.     private $products;
  82.     /**
  83.      * @ORM\ManyToOne(targetEntity="App\Entity\Region", inversedBy="companyLocations")
  84.      * @Groups({"searchable"})
  85.      */
  86.     private $region;
  87.     /**
  88.      * @ORM\Column(type="boolean")
  89.      */
  90.     private $showPublic=true;
  91.     public function __construct()
  92.     {
  93.         $this->products = new ArrayCollection();
  94.     }
  95.     public function getId(): ?int
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getFullAddress(): ?string
  100.     {
  101.         return $this->civicNumber.' '.$this->streetName.', '.$this->city.' '.$this->province.' '.$this->zipCode;
  102.     }
  103.     public function getFullAddressWithName(): ?string
  104.     {
  105.         //In theory only the Main address should be empty
  106.         if(empty($this->name))
  107.             $name 'Bureau principal';
  108.         else
  109.             $name $this->name;
  110.         return $name.' - '.$this->civicNumber.' '.$this->streetName.', '.$this->city.' '.$this->province.' '.$this->zipCode;
  111.     }
  112.     public function getStreetAddress(): ?string
  113.     {
  114.         return $this->civicNumber.' '.$this->streetName;
  115.     }
  116.     public function getCivicNumber(): ?string
  117.     {
  118.         return $this->civicNumber;
  119.     }
  120.     public function setCivicNumber(string $civicNumber): self
  121.     {
  122.         $this->civicNumber $civicNumber;
  123.         return $this;
  124.     }
  125.     public function getStreetName(): ?string
  126.     {
  127.         return $this->streetName;
  128.     }
  129.     public function setStreetName(string $streetName): self
  130.     {
  131.         $this->streetName $streetName;
  132.         return $this;
  133.     }
  134.     public function getCity(): ?string
  135.     {
  136.         return $this->city;
  137.     }
  138.     public function setCity(string $city): self
  139.     {
  140.         $this->city $city;
  141.         return $this;
  142.     }
  143.     public function getZipCode(): ?string
  144.     {
  145.         return $this->zipCode;
  146.     }
  147.     public function setZipCode(string $zipCode): self
  148.     {
  149.         $this->zipCode $zipCode;
  150.         return $this;
  151.     }
  152.     public function getProvince(): ?string
  153.     {
  154.         return $this->province;
  155.     }
  156.     public function setProvince(string $province): self
  157.     {
  158.         $this->province $province;
  159.         return $this;
  160.     }
  161.     public function getCountry(): ?string
  162.     {
  163.         return $this->country;
  164.     }
  165.     public function setCountry(string $country): self
  166.     {
  167.         $this->country $country;
  168.         return $this;
  169.     }
  170.     public function getPhone(): ?string
  171.     {
  172.         return $this->phone;
  173.     }
  174.     public function setPhone(string $phone): self
  175.     {
  176.         $this->phone $phone;
  177.         return $this;
  178.     }
  179.     public function getPhoneExtension(): ?string
  180.     {
  181.         return $this->phoneExtension;
  182.     }
  183.     public function setPhoneExtension(?string $phoneExtension): self
  184.     {
  185.         $this->phoneExtension $phoneExtension;
  186.         return $this;
  187.     }
  188.     public function getEmail(): ?string
  189.     {
  190.         return $this->email;
  191.     }
  192.     public function setEmail(?string $email): self
  193.     {
  194.         $this->email $email;
  195.         return $this;
  196.     }
  197.     public function getCompany(): ?Company
  198.     {
  199.         return $this->company;
  200.     }
  201.     public function setCompany(?Company $company): self
  202.     {
  203.         $this->company $company;
  204.         return $this;
  205.     }
  206.     public function getMobilePhone(): ?string
  207.     {
  208.         return $this->mobilePhone;
  209.     }
  210.     public function setMobilePhone(?string $mobilePhone): self
  211.     {
  212.         $this->mobilePhone $mobilePhone;
  213.         return $this;
  214.     }
  215.     public function getName(): ?string
  216.     {
  217.         return $this->name;
  218.     }
  219.     public function setName(?string $name): self
  220.     {
  221.         $this->name $name;
  222.         return $this;
  223.     }
  224.     public function getNotesForBuyer(): ?string
  225.     {
  226.         return $this->notesForBuyer;
  227.     }
  228.     public function setNotesForBuyer(?string $notesForBuyer): self
  229.     {
  230.         $this->notesForBuyer $notesForBuyer;
  231.         return $this;
  232.     }
  233.     public function getPickUp(): ?bool
  234.     {
  235.         return $this->pickUp;
  236.     }
  237.     public function setPickUp(bool $pickUp): self
  238.     {
  239.         $this->pickUp $pickUp;
  240.         return $this;
  241.     }
  242.     /**
  243.      * @return Collection|Product[]
  244.      */
  245.     public function getProducts(): Collection
  246.     {
  247.         return $this->products;
  248.     }
  249.     public function addProduct(Product $product): self
  250.     {
  251.         if (!$this->products->contains($product)) {
  252.             $this->products[] = $product;
  253.             $product->addLocation($this);
  254.         }
  255.         return $this;
  256.     }
  257.     public function removeProduct(Product $product): self
  258.     {
  259.         if ($this->products->contains($product)) {
  260.             $this->products->removeElement($product);
  261.             $product->removeLocation($this);
  262.         }
  263.         return $this;
  264.     }
  265.     public function getRegion(): ?Region
  266.     {
  267.         return $this->region;
  268.     }
  269.     public function setRegion(?Region $region): self
  270.     {
  271.         $this->region $region;
  272.         return $this;
  273.     }
  274.     public function getShowPublic(): ?bool
  275.     {
  276.         return $this->showPublic;
  277.     }
  278.     public function setShowPublic(bool $showPublic): self
  279.     {
  280.         $this->showPublic $showPublic;
  281.         return $this;
  282.     }
  283.     public function __toString()
  284.     {
  285.         return $this->getFullAddressWithName();
  286.     }
  287. }