src/Entity/WinWOP/ModulesRequest.php line 21

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2019, MND Next GmbH - www.mndnext.de
  4.  */
  5. namespace App\Entity\WinWOP;
  6. use App\Entity\Machine;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. /**
  13.  * @ORM\Entity
  14.  * @ORM\HasLifecycleCallbacks()
  15.  * @ORM\Table(name="win_wop_modules_requests")
  16.  * @Vich\Uploadable
  17.  */
  18. class ModulesRequest
  19. {
  20.     /**
  21.      * @ORM\Id
  22.      * @ORM\Column(type="integer")
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      */
  25.     protected $id;
  26.     /**
  27.      * @ORM\OneToOne(targetEntity="App\Entity\Machine", inversedBy="modules_request", cascade={"persist"})
  28.      */
  29.     private $machine;
  30.     /**
  31.      * @var \DateTime
  32.      *
  33.      * @ORM\Column(name="created", type="datetime", nullable=false)
  34.      */
  35.     private $created;
  36.     /**
  37.      * @ORM\ManyToMany(targetEntity="Module")
  38.      * @ORM\JoinTable(name="win_wop_modules_requests_modules",
  39.      *      joinColumns={@ORM\JoinColumn(name="module_id", referencedColumnName="id")},
  40.      *      inverseJoinColumns={@ORM\JoinColumn(name="request_id", referencedColumnName="id")}
  41.      *      )
  42.      */
  43.     private $modules;
  44.     /**
  45.      * Constructor
  46.      */
  47.     public function __construct()
  48.     {
  49.         $this->created = new \DateTime();
  50.         $this->modules = new \Doctrine\Common\Collections\ArrayCollection();
  51.     }
  52.     public function getId()
  53.     {
  54.         return $this->id;
  55.     }
  56.     public function setCreated($created)
  57.     {
  58.         $this->created $created;
  59.         return $this;
  60.     }
  61.     public function getCreated()
  62.     {
  63.         return $this->created;
  64.     }
  65.     public function setMachine(Machine $machine null)
  66.     {
  67.         $this->machine $machine;
  68.         return $this;
  69.     }
  70.     public function getMachine() : ?Machine
  71.     {
  72.         return $this->machine;
  73.     }
  74.     public function addModule(Module $module)
  75.     {
  76.         if (!$this->modules->contains($module)) {
  77.             $this->modules->add($module);
  78.         }
  79.     }
  80.     /**
  81.      * @return Collection|Module[]
  82.      */
  83.     public function getModules() : Collection
  84.     {
  85.         return $this->modules;
  86.     }
  87.     public function __toString()
  88.     {
  89.         $date $this->getCreated();
  90.         if ($date) {
  91.             return $date->format('d.m.Y H:i');
  92.         }
  93.         return '';
  94.     }
  95. }