src/Entity/Dispatch/Dispatch.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Dispatch;
  3. use App\Entity\AppUser;
  4. use App\Entity\Documentation\HouseGuide;
  5. use App\Entity\Documentation\MasterGuide;
  6. use App\Entity\Documentation\MasterGuideNumber;
  7. use App\Entity\Shipping;
  8. use App\Repository\Dispatch\DispatchRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. /**
  13.  * @ORM\Entity(repositoryClass=DispatchRepository::class)
  14.  */
  15. class Dispatch
  16. {
  17.     const CREATED 'created';
  18.     const CANCELLED 'cancelled';
  19.     const CONFIRMED 'confirmed';
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue
  23.      * @ORM\Column(type="integer")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @ORM\ManyToOne(targetEntity=MasterGuideNumber::class, inversedBy="dispatches")
  28.      * @ORM\JoinColumn(nullable=false)
  29.      */
  30.     private $masterGuideNumber;
  31.     /**
  32.      * @ORM\OneToMany(targetEntity=HouseGuide::class, mappedBy="dispatch")
  33.      */
  34.     private $houseGuides;
  35.     /**
  36.      * @ORM\Column(type="datetime_immutable")
  37.      */
  38.     private $createdAt;
  39.     /**
  40.      * @ORM\ManyToOne(targetEntity=AppUser::class, inversedBy="dispatches")
  41.      * @ORM\JoinColumn(nullable=false)
  42.      */
  43.     private $createdBy;
  44.     /**
  45.      * @ORM\OneToMany(targetEntity=Shipping::class, mappedBy="dispatch")
  46.      */
  47.     private $shippings;
  48.     /**
  49.      * @ORM\OneToOne(targetEntity=MasterGuide::class, cascade={"persist", "remove"})
  50.      * @ORM\JoinColumn(nullable=false)
  51.      */
  52.     private $masterGuide;
  53.     /**
  54.      * @ORM\Column(type="string", length=255)
  55.      */
  56.     private $status;
  57.     /**
  58.      * @ORM\OneToMany(targetEntity=Log::class, mappedBy="dispatch")
  59.      */
  60.     private $logs;
  61.     public function __construct()
  62.     {
  63.         $this->houseGuides = new ArrayCollection();
  64.         $this->shippings = new ArrayCollection();
  65.         $this->logs = new ArrayCollection();
  66.         $this->status Dispatch::CREATED;
  67.     }
  68.     public function getId(): ?int
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getMasterGuideNumber(): ?MasterGuideNumber
  73.     {
  74.         return $this->masterGuideNumber;
  75.     }
  76.     public function setMasterGuideNumber(?MasterGuideNumber $masterGuideNumber): self
  77.     {
  78.         $this->masterGuideNumber $masterGuideNumber;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection<int, HouseGuide>
  83.      */
  84.     public function getHouseGuides(): Collection
  85.     {
  86.         return $this->houseGuides;
  87.     }
  88.     public function addHouseGuide(HouseGuide $houseGuide): self
  89.     {
  90.         if (!$this->houseGuides->contains($houseGuide)) {
  91.             $this->houseGuides[] = $houseGuide;
  92.             $houseGuide->setDispatch($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeHouseGuide(HouseGuide $houseGuide): self
  97.     {
  98.         if ($this->houseGuides->removeElement($houseGuide)) {
  99.             // set the owning side to null (unless already changed)
  100.             if ($houseGuide->getDispatch() === $this) {
  101.                 $houseGuide->setDispatch(null);
  102.             }
  103.         }
  104.         return $this;
  105.     }
  106.     public function getCreatedAt(): ?\DateTimeImmutable
  107.     {
  108.         return $this->createdAt;
  109.     }
  110.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  111.     {
  112.         $this->createdAt $createdAt;
  113.         return $this;
  114.     }
  115.     public function getCreatedBy(): ?AppUser
  116.     {
  117.         return $this->createdBy;
  118.     }
  119.     public function setCreatedBy(?AppUser $createdBy): self
  120.     {
  121.         $this->createdBy $createdBy;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return Collection<int, Shipping>
  126.      */
  127.     public function getShippings(): Collection
  128.     {
  129.         return $this->shippings;
  130.     }
  131.     public function addShipping(Shipping $shipping): self
  132.     {
  133.         if (!$this->shippings->contains($shipping)) {
  134.             $this->shippings[] = $shipping;
  135.             $shipping->setDispatch($this);
  136.         }
  137.         return $this;
  138.     }
  139.     public function removeShipping(Shipping $shipping): self
  140.     {
  141.         if ($this->shippings->removeElement($shipping)) {
  142.             // set the owning side to null (unless already changed)
  143.             if ($shipping->getDispatch() === $this) {
  144.                 $shipping->setDispatch(null);
  145.             }
  146.         }
  147.         return $this;
  148.     }
  149.     public function getMasterGuide(): ?MasterGuide
  150.     {
  151.         return $this->masterGuide;
  152.     }
  153.     public function setMasterGuide(MasterGuide $masterGuide): self
  154.     {
  155.         $this->masterGuide $masterGuide;
  156.         return $this;
  157.     }
  158.     public function getStatus(): ?string
  159.     {
  160.         return $this->status;
  161.     }
  162.     public function setStatus(string $status): self
  163.     {
  164.         $this->status $status;
  165.         return $this;
  166.     }
  167.     /**
  168.      * @return Collection<int, Log>
  169.      */
  170.     public function getLogs(): Collection
  171.     {
  172.         return $this->logs;
  173.     }
  174.     public function addLog(Log $log): self
  175.     {
  176.         if (!$this->logs->contains($log)) {
  177.             $this->logs[] = $log;
  178.             $log->setDispatch($this);
  179.         }
  180.         return $this;
  181.     }
  182.     public function removeLog(Log $log): self
  183.     {
  184.         if ($this->logs->removeElement($log)) {
  185.             // set the owning side to null (unless already changed)
  186.             if ($log->getDispatch() === $this) {
  187.                 $log->setDispatch(null);
  188.             }
  189.         }
  190.         return $this;
  191.     }
  192. }