<?php/** * Copyright (c) 2019, MND Next GmbH - www.mndnext.de */namespace App\Entity\WinWOP;use App\Entity\Machine;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Component\HttpFoundation\File\File;use Vich\UploaderBundle\Mapping\Annotation as Vich;use Symfony\Component\Validator\Constraints as Assert;/** * @ORM\Entity * @ORM\HasLifecycleCallbacks() * @ORM\Table(name="win_wop_modules_requests") * @Vich\Uploadable */class ModulesRequest{ /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue(strategy="AUTO") */ protected $id; /** * @ORM\OneToOne(targetEntity="App\Entity\Machine", inversedBy="modules_request", cascade={"persist"}) */ private $machine; /** * @var \DateTime * * @ORM\Column(name="created", type="datetime", nullable=false) */ private $created; /** * @ORM\ManyToMany(targetEntity="Module") * @ORM\JoinTable(name="win_wop_modules_requests_modules", * joinColumns={@ORM\JoinColumn(name="module_id", referencedColumnName="id")}, * inverseJoinColumns={@ORM\JoinColumn(name="request_id", referencedColumnName="id")} * ) */ private $modules; /** * Constructor */ public function __construct() { $this->created = new \DateTime(); $this->modules = new \Doctrine\Common\Collections\ArrayCollection(); } public function getId() { return $this->id; } public function setCreated($created) { $this->created = $created; return $this; } public function getCreated() { return $this->created; } public function setMachine(Machine $machine = null) { $this->machine = $machine; return $this; } public function getMachine() : ?Machine { return $this->machine; } public function addModule(Module $module) { if (!$this->modules->contains($module)) { $this->modules->add($module); } } /** * @return Collection|Module[] */ public function getModules() : Collection { return $this->modules; } public function __toString() { $date = $this->getCreated(); if ($date) { return $date->format('d.m.Y H:i'); } return ''; }}