<?php
namespace App\Entity\Dispatch;
use App\Entity\AppUser;
use App\Entity\Documentation\HouseGuide;
use App\Entity\Documentation\MasterGuide;
use App\Entity\Documentation\MasterGuideNumber;
use App\Entity\Shipping;
use App\Repository\Dispatch\DispatchRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=DispatchRepository::class)
*/
class Dispatch
{
const CREATED = 'created';
const CANCELLED = 'cancelled';
const CONFIRMED = 'confirmed';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=MasterGuideNumber::class, inversedBy="dispatches")
* @ORM\JoinColumn(nullable=false)
*/
private $masterGuideNumber;
/**
* @ORM\OneToMany(targetEntity=HouseGuide::class, mappedBy="dispatch")
*/
private $houseGuides;
/**
* @ORM\Column(type="datetime_immutable")
*/
private $createdAt;
/**
* @ORM\ManyToOne(targetEntity=AppUser::class, inversedBy="dispatches")
* @ORM\JoinColumn(nullable=false)
*/
private $createdBy;
/**
* @ORM\OneToMany(targetEntity=Shipping::class, mappedBy="dispatch")
*/
private $shippings;
/**
* @ORM\OneToOne(targetEntity=MasterGuide::class, cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $masterGuide;
/**
* @ORM\Column(type="string", length=255)
*/
private $status;
/**
* @ORM\OneToMany(targetEntity=Log::class, mappedBy="dispatch")
*/
private $logs;
public function __construct()
{
$this->houseGuides = new ArrayCollection();
$this->shippings = new ArrayCollection();
$this->logs = new ArrayCollection();
$this->status = Dispatch::CREATED;
}
public function getId(): ?int
{
return $this->id;
}
public function getMasterGuideNumber(): ?MasterGuideNumber
{
return $this->masterGuideNumber;
}
public function setMasterGuideNumber(?MasterGuideNumber $masterGuideNumber): self
{
$this->masterGuideNumber = $masterGuideNumber;
return $this;
}
/**
* @return Collection<int, HouseGuide>
*/
public function getHouseGuides(): Collection
{
return $this->houseGuides;
}
public function addHouseGuide(HouseGuide $houseGuide): self
{
if (!$this->houseGuides->contains($houseGuide)) {
$this->houseGuides[] = $houseGuide;
$houseGuide->setDispatch($this);
}
return $this;
}
public function removeHouseGuide(HouseGuide $houseGuide): self
{
if ($this->houseGuides->removeElement($houseGuide)) {
// set the owning side to null (unless already changed)
if ($houseGuide->getDispatch() === $this) {
$houseGuide->setDispatch(null);
}
}
return $this;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getCreatedBy(): ?AppUser
{
return $this->createdBy;
}
public function setCreatedBy(?AppUser $createdBy): self
{
$this->createdBy = $createdBy;
return $this;
}
/**
* @return Collection<int, Shipping>
*/
public function getShippings(): Collection
{
return $this->shippings;
}
public function addShipping(Shipping $shipping): self
{
if (!$this->shippings->contains($shipping)) {
$this->shippings[] = $shipping;
$shipping->setDispatch($this);
}
return $this;
}
public function removeShipping(Shipping $shipping): self
{
if ($this->shippings->removeElement($shipping)) {
// set the owning side to null (unless already changed)
if ($shipping->getDispatch() === $this) {
$shipping->setDispatch(null);
}
}
return $this;
}
public function getMasterGuide(): ?MasterGuide
{
return $this->masterGuide;
}
public function setMasterGuide(MasterGuide $masterGuide): self
{
$this->masterGuide = $masterGuide;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(string $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, Log>
*/
public function getLogs(): Collection
{
return $this->logs;
}
public function addLog(Log $log): self
{
if (!$this->logs->contains($log)) {
$this->logs[] = $log;
$log->setDispatch($this);
}
return $this;
}
public function removeLog(Log $log): self
{
if ($this->logs->removeElement($log)) {
// set the owning side to null (unless already changed)
if ($log->getDispatch() === $this) {
$log->setDispatch(null);
}
}
return $this;
}
}