src/Entity/Machine.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\MachineRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. /**
  9.  * @ORM\Entity(repositoryClass=MachineRepository::class)
  10.  */
  11. class Machine
  12. {
  13.     use TimestampableEntity;
  14.     /**
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue
  17.      * @ORM\Column(type="integer")
  18.      */
  19.     private $id;
  20.     /**
  21.      * @ORM\Column(type="string", length=255)
  22.      */
  23.     private $name;
  24.     /**
  25.      * @ORM\Column(type="string", length=255)
  26.      */
  27.     private $code;
  28.     /**
  29.      * @ORM\Column(type="text", nullable=true)
  30.      */
  31.     private $invoiceDescription;
  32.     /**
  33.      * @ORM\Column(type="text", nullable=true)
  34.      */
  35.     private $technicalNotes;
  36.     /**
  37.      * @ORM\ManyToOne(targetEntity=Machine::class, inversedBy="children")
  38.      * @ORM\JoinColumn(name="parent_id", referencedColumnName="id" )
  39.      */
  40.     private $parent;
  41.     /**
  42.      * @ORM\OneToMany(targetEntity=Machine::class, mappedBy="parent")
  43.      */
  44.     private $children;
  45.     /**
  46.      * @ORM\ManyToMany(targetEntity=PaperSize::class, mappedBy="machines", cascade={"persist"})
  47.      */
  48.     private $paperSizes;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity=MachinePaperSizeMatrix::class, mappedBy="machine")
  51.      */
  52.     private $machinePaperSizeMatrices;
  53.     /**
  54.      * @ORM\ManyToMany(targetEntity=Task::class, inversedBy="machines")
  55.      */
  56.     private $tasks;
  57.     /**
  58.      * @ORM\Column(type="integer", nullable=true)
  59.      */
  60.     private $waste;
  61.     /**
  62.      * @ORM\Column(type="decimal", precision=10, scale=3, nullable=true)
  63.      */
  64.     private $spoilage;
  65.     /**
  66.      * @ORM\Column(type="integer", nullable=true)
  67.      */
  68.     private $setupTime;
  69.     /**
  70.      * @ORM\Column(type="decimal", precision=10, scale=4, nullable=true)
  71.      */
  72.     private $rate;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=MachineCostMatrix::class, mappedBy="machine", orphanRemoval=true, cascade={"persist", "remove"})
  75.      */
  76.     private $machineCostMatrices;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity=MachineTimeMatrix::class, mappedBy="machine", orphanRemoval=true, cascade={"persist", "remove"})
  79.      */
  80.     private $machineTimeMatrices;
  81.     public function __construct()
  82.     {
  83.         $this->children = new ArrayCollection();
  84.         $this->paperSizes = new ArrayCollection();
  85.         $this->machinePaperSizeMatrices = new ArrayCollection();
  86.         $this->tasks = new ArrayCollection();
  87.         $this->machineCostMatrices = new ArrayCollection();
  88.         $this->machineTimeMatrices = new ArrayCollection();
  89.     }
  90.     public function getId(): ?int
  91.     {
  92.         return $this->id;
  93.     }
  94.     public function getName(): ?string
  95.     {
  96.         return $this->name;
  97.     }
  98.     public function setName(string $name): self
  99.     {
  100.         $this->name $name;
  101.         return $this;
  102.     }
  103.     public function getCode(): ?string
  104.     {
  105.         return $this->code;
  106.     }
  107.     public function setCode(string $code): self
  108.     {
  109.         $this->code $code;
  110.         return $this;
  111.     }
  112.     public function getInvoiceDescription(): ?string
  113.     {
  114.         return $this->invoiceDescription;
  115.     }
  116.     public function setInvoiceDescription(?string $invoiceDescription): self
  117.     {
  118.         $this->invoiceDescription $invoiceDescription;
  119.         return $this;
  120.     }
  121.     public function getTechnicalNotes(): ?string
  122.     {
  123.         return $this->technicalNotes;
  124.     }
  125.     public function setTechnicalNotes(?string $technicalNotes): self
  126.     {
  127.         $this->technicalNotes $technicalNotes;
  128.         return $this;
  129.     }
  130.     public function getParent(): ?self
  131.     {
  132.         return $this->parent;
  133.     }
  134.     public function setParent(?self $parent): self
  135.     {
  136.         $this->parent $parent;
  137.         return $this;
  138.     }
  139.     /**
  140.      * @return Collection<int, self>
  141.      */
  142.     public function getChildren(): Collection
  143.     {
  144.         return $this->children;
  145.     }
  146.     public function addChild(self $child): self
  147.     {
  148.         if (!$this->children->contains($child)) {
  149.             $this->children[] = $child;
  150.             $child->setParent($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeChild(self $child): self
  155.     {
  156.         if ($this->children->removeElement($child)) {
  157.             // set the owning side to null (unless already changed)
  158.             if ($child->getParent() === $this) {
  159.                 $child->setParent(null);
  160.             }
  161.         }
  162.         return $this;
  163.     }
  164.     /**
  165.      * @return Collection<int, PaperSize>
  166.      */
  167.     public function getPaperSizes(): Collection
  168.     {
  169.         return $this->paperSizes;
  170.     }
  171.     public function addPaperSize(PaperSize $paperSize): self
  172.     {
  173.         if (!$this->paperSizes->contains($paperSize)) {
  174.             $this->paperSizes[] = $paperSize;
  175.             $paperSize->addMachine($this);
  176.         }
  177.         return $this;
  178.     }
  179.     public function removePaperSize(PaperSize $paperSize): self
  180.     {
  181.         if ($this->paperSizes->removeElement($paperSize)) {
  182.             $paperSize->removeMachine($this);
  183.         }
  184.         return $this;
  185.     }
  186.     /**
  187.      * @return Collection<int, MachinePaperSizeMatrix>
  188.      */
  189.     public function getMachinePaperSizeMatrices(): Collection
  190.     {
  191.         return $this->machinePaperSizeMatrices;
  192.     }
  193.     public function addMachinePaperSizeMatrix(MachinePaperSizeMatrix $machinePaperSizeMatrix): self
  194.     {
  195.         if (!$this->machinePaperSizeMatrices->contains($machinePaperSizeMatrix)) {
  196.             $this->machinePaperSizeMatrices[] = $machinePaperSizeMatrix;
  197.             $machinePaperSizeMatrix->setMachine($this);
  198.         }
  199.         return $this;
  200.     }
  201.     public function removeMachinePaperSizeMatrix(MachinePaperSizeMatrix $machinePaperSizeMatrix): self
  202.     {
  203.         if ($this->machinePaperSizeMatrices->removeElement($machinePaperSizeMatrix)) {
  204.             // set the owning side to null (unless already changed)
  205.             if ($machinePaperSizeMatrix->getMachine() === $this) {
  206.                 $machinePaperSizeMatrix->setMachine(null);
  207.             }
  208.         }
  209.         return $this;
  210.     }
  211.     /**
  212.      * @return Collection<int, Task>
  213.      */
  214.     public function getTasks(): Collection
  215.     {
  216.         return $this->tasks;
  217.     }
  218.     public function addTask(Task $task): self
  219.     {
  220.         if (!$this->tasks->contains($task)) {
  221.             $this->tasks[] = $task;
  222.         }
  223.         return $this;
  224.     }
  225.     public function removeTask(Task $task): self
  226.     {
  227.         $this->tasks->removeElement($task);
  228.         return $this;
  229.     }
  230.     public function getWaste(): ?int
  231.     {
  232.         return $this->waste;
  233.     }
  234.     public function setWaste(?int $waste): self
  235.     {
  236.         $this->waste $waste;
  237.         return $this;
  238.     }
  239.     public function getSpoilage(): ?string
  240.     {
  241.         return $this->spoilage;
  242.     }
  243.     public function setSpoilage(?string $spoilage): self
  244.     {
  245.         $this->spoilage $spoilage;
  246.         return $this;
  247.     }
  248.     public function getSetupTime(): ?int
  249.     {
  250.         return $this->setupTime;
  251.     }
  252.     public function setSetupTime(?int $setupTime): self
  253.     {
  254.         $this->setupTime $setupTime;
  255.         return $this;
  256.     }
  257.     public function getRate(): ?string
  258.     {
  259.         return $this->rate;
  260.     }
  261.     public function setRate(?string $rate): self
  262.     {
  263.         $this->rate $rate;
  264.         return $this;
  265.     }
  266.     /**
  267.      * @return Collection<int, MachineCostMatrix>
  268.      */
  269.     public function getMachineCostMatrices(): Collection
  270.     {
  271.         return $this->machineCostMatrices;
  272.     }
  273.     public function addMachineCostMatrix(MachineCostMatrix $machineCostMatrix): self
  274.     {
  275.         if (!$this->machineCostMatrices->contains($machineCostMatrix)) {
  276.             $this->machineCostMatrices[] = $machineCostMatrix;
  277.             $machineCostMatrix->setMachine($this);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeMachineCostMatrix(MachineCostMatrix $machineCostMatrix): self
  282.     {
  283.         if ($this->machineCostMatrices->removeElement($machineCostMatrix)) {
  284.             // set the owning side to null (unless already changed)
  285.             if ($machineCostMatrix->getMachine() === $this) {
  286.                 $machineCostMatrix->setMachine(null);
  287.             }
  288.         }
  289.         return $this;
  290.     }
  291.     /**
  292.      * @return Collection<int, MachineTimeMatrix>
  293.      */
  294.     public function getMachineTimeMatrices(): Collection
  295.     {
  296.         return $this->machineTimeMatrices;
  297.     }
  298.     public function addMachineTimeMatrix(MachineTimeMatrix $machineTimeMatrix): self
  299.     {
  300.         if (!$this->machineTimeMatrices->contains($machineTimeMatrix)) {
  301.             $this->machineTimeMatrices[] = $machineTimeMatrix;
  302.             $machineTimeMatrix->setMachine($this);
  303.         }
  304.         return $this;
  305.     }
  306.     public function removeMachineTimeMatrix(MachineTimeMatrix $machineTimeMatrix): self
  307.     {
  308.         if ($this->machineTimeMatrices->removeElement($machineTimeMatrix)) {
  309.             // set the owning side to null (unless already changed)
  310.             if ($machineTimeMatrix->getMachine() === $this) {
  311.                 $machineTimeMatrix->setMachine(null);
  312.             }
  313.         }
  314.         return $this;
  315.     }
  316.     public function __clone() {
  317.        $this->id null;
  318.     }
  319.     public function getCalculatorDisplayName():string
  320.     {
  321.         return '['.$this->code.']['.$this->name.']';
  322.     }
  323.     public function __toString() {
  324.         return $this->name;
  325.     }
  326. }