src/Entity/Equipos/Maquinaria.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Equipos;
  3. use App\Repository\Equipos\MaquinariaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use App\Entity\Almacen\Articulo;
  11. use App\Entity\Mantenimiento\SectorPlanta;
  12. /**
  13.  * @ORM\Entity(repositoryClass=MaquinariaRepository::class)
  14.  * @ORM\Table(name="mant_maquinarias")
  15.  * @UniqueEntity(
  16.  *     fields={"nombre"},
  17.  *     errorPath="nombre",
  18.  *     message="Ya existe una maquinaria con el nombre ingresado"
  19.  * )
  20.  */
  21. class Maquinaria
  22. {
  23.     /**
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="text")
  31.      * @Assert\NotNull(message="El campo es requerido")
  32.      */
  33.     private $nombre;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $codigo;
  38.     /**
  39.      * @ORM\Column(type="boolean")
  40.      */
  41.     private $activo true;
  42.     /**
  43.      * @ORM\ManyToMany(targetEntity=Articulo::class, mappedBy="maquinarias")
  44.      */
  45.     private $articulos;
  46.     /**
  47.      * @ORM\ManyToOne(targetEntity=SectorPlanta::class)
  48.      * @ORM\JoinColumn(name="id_sector", referencedColumnName="id", nullable=true)
  49.      */
  50.     private $sector;
  51.     public function __construct()
  52.     {
  53.         $this->articulos = new ArrayCollection();
  54.     }
  55.     
  56.     public function __toString()
  57.     {
  58.         return $this->nombre;
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getNombre(): ?string
  65.     {
  66.         return $this->nombre;
  67.     }
  68.     public function setNombre(string $nombre): self
  69.     {
  70.         $this->nombre $nombre;
  71.         return $this;
  72.     }
  73.     public function getCodigo(): ?string
  74.     {
  75.         return $this->codigo;
  76.     }
  77.     public function setCodigo(?string $codigo): self
  78.     {
  79.         $this->codigo $codigo;
  80.         return $this;
  81.     }
  82.     /**
  83.      * @return Collection<int, Articulo>
  84.      */
  85.     public function getArticulos(): Collection
  86.     {
  87.         return $this->articulos;
  88.     }
  89.     public function addArticulo(Articulo $articulo): self
  90.     {
  91.         if (!$this->articulos->contains($articulo)) {
  92.             $this->articulos[] = $articulo;
  93.             $articulo->addMaquinaria($this);
  94.         }
  95.         return $this;
  96.     }
  97.     public function removeArticulo(Articulo $articulo): self
  98.     {
  99.         if ($this->articulos->removeElement($articulo)) {
  100.             $articulo->removeMaquinaria($this);
  101.         }
  102.         return $this;
  103.     }
  104.     public function getSector(): ?SectorPlanta
  105.     {
  106.         return $this->sector;
  107.     }
  108.     public function setSector(?SectorPlanta $sector): self
  109.     {
  110.         $this->sector $sector;
  111.         return $this;
  112.     }
  113.     public function isActivo(): ?bool
  114.     {
  115.         return $this->activo;
  116.     }
  117.     public function setActivo(bool $activo): self
  118.     {
  119.         $this->activo $activo;
  120.         return $this;
  121.     }
  122. }