<?php
namespace App\Entity\Slave;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_s_destination")
* @ORM\Entity(repositoryClass="App\Repository\Slave\DestinationRepository")
*/
class Destination
{
public function __toString(){
return $this->getName();
}
public function getCanDelete($user){
if(!$this->warehouse->getCanDelete($user)) return false;
return true;
}
public function displayAddress(){
$result = '';
if($this->address != null) $result.= $this->address;
if($this->civic != null) $result.= ' '.$this->civic;
if($this->zip != null) $result.= ', '.$this->zip;
return $result;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="name", type="string", length=191)
*/
protected $name;
/**
* @ORM\Column(name="phone", type="string", nullable=true, length=191)
*/
protected $phone;
/**
* @ORM\Column(name="address", type="string", nullable=true, length=191)
*/
protected $address;
/**
* @ORM\Column(name="civic", type="string", nullable=true, length=191)
*/
protected $civic;
/**
* @ORM\Column(name="zip", type="string", nullable=true, length=191)
*/
protected $zip;
/**
* @ORM\Column(name="email", type="string", nullable=true, length=191)
*/
protected $email;
/**
* @ORM\Column(name="id_city", type="bigint", nullable=true)
*/
protected $idCity;
// OneToOne
/**
* @ORM\OneToOne(targetEntity="App\Entity\Slave\Warehouse", mappedBy="destination")
*/
private $warehouse;
//
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getCivic(): ?string
{
return $this->civic;
}
public function setCivic(?string $civic): self
{
$this->civic = $civic;
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(?string $zip): self
{
$this->zip = $zip;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getIdCity(): ?string
{
return $this->idCity;
}
public function setIdCity(?string $idCity): self
{
$this->idCity = $idCity;
return $this;
}
public function getWarehouse(): ?Warehouse
{
return $this->warehouse;
}
public function setWarehouse(?Warehouse $warehouse): self
{
// unset the owning side of the relation if necessary
if ($warehouse === null && $this->warehouse !== null) {
$this->warehouse->setDestination(null);
}
// set the owning side of the relation if necessary
if ($warehouse !== null && $warehouse->getDestination() !== $this) {
$warehouse->setDestination($this);
}
$this->warehouse = $warehouse;
return $this;
}
}