src/Entity/Marca.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as JMS;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  13. /**
  14.  * @ORM\Entity(repositoryClass="App\Repository\MarcaRepository")
  15.  * @ORM\Table(name="marca")
  16.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  17.  * @Vich\Uploadable
  18.  * @UniqueEntity("nombre")
  19.  */
  20. class Marca
  21. {
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\Column(type="bigint", options={"unsigned":true})
  25.      * @ORM\GeneratedValue(strategy="AUTO")
  26.      * @JMS\Groups({
  27.      *      "api_v1_marca_serialize",
  28.      *      "api_v1_valoracion_serialize",
  29.      *      "api_v1_operacion_show_serialize"
  30.      * })
  31.      */
  32.     protected $id;
  33.     /**
  34.      * @ORM\Column(type="string", nullable=false)
  35.      * @JMS\Groups({
  36.      *       "api_v1_marca_serialize",
  37.      *       "api_v1_valoracion_serialize",
  38.      *       "api_v1_operacion_show_serialize"
  39.      *  })
  40.      */
  41.     protected $nombre;
  42.     /**
  43.      * @ORM\Column(type="string", nullable=true)
  44.      */
  45.     protected $logo;
  46.     /** @Vich\UploadableField(mapping="marca", fileNameProperty="logo")
  47.      * @var File
  48.      */
  49.     protected $logoFile;
  50.     /**
  51.      * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  52.      * @JMS\Groups({
  53.      *       "api_v1_marca_serialize",
  54.      *       "api_v1_valoracion_serialize",
  55.      *       "api_v1_operacion_show_serialize"
  56.      *  })
  57.      */
  58.     protected $deletedAt;
  59.     /**
  60.      * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  61.      * @Gedmo\Timestampable(on="update")
  62.      */
  63.     protected $updatedAt;
  64.     /**
  65.      * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  66.      * @Gedmo\Timestampable(on="create")
  67.      */
  68.     protected $createdAt;
  69.     /**
  70.      * @ORM\OneToMany(targetEntity="App\Entity\Reloj", mappedBy="marca")
  71.      */
  72.     protected $relojes;
  73.     /**
  74.      * @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="relojMarca")
  75.      */
  76.     private $actividades;
  77.     /**
  78.      * @ORM\OneToMany(targetEntity="App\Entity\ValoracionesRelojes", mappedBy="relojMarca")
  79.      */
  80.     protected $valoracionesRelojes;
  81.     /**
  82.      * @ORM\OneToMany(targetEntity="App\Entity\DetalleOperacion", mappedBy="marca")
  83.      */
  84.     protected $detalleOperaciones;
  85.     public function __construct()
  86.     {
  87.         $this->relojes = new ArrayCollection();
  88.         $this->valoracionesRelojes = new ArrayCollection();
  89.         $this->detalleOperaciones = new ArrayCollection();
  90.         $this->actividades = new ArrayCollection();
  91.     }
  92.     public function __toString(): string
  93.     {
  94.         return $this->getNombre();
  95.     }
  96.     public function getId(): ?string
  97.     {
  98.         return $this->id;
  99.     }
  100.     public function getNombre(): ?string
  101.     {
  102.         return $this->nombre;
  103.     }
  104.     public function setNombre(string $nombre): self
  105.     {
  106.         $this->nombre $nombre;
  107.         return $this;
  108.     }
  109.     public function getLogo(): ?string
  110.     {
  111.         return $this->logo;
  112.     }
  113.     public function setLogo(?string $logo): self
  114.     {
  115.         $this->logo $logo;
  116.         return $this;
  117.     }
  118.     public function getLogoFile(): ?File
  119.     {
  120.         return $this->logoFile;
  121.     }
  122.     public function setLogoFile(?File $logoFile): self
  123.     {
  124.         $this->logoFile $logoFile;
  125.         if ($logoFile) {
  126.             // if 'updatedAt' is not defined in your entity, use another property
  127.             $this->setUpdatedAt(new \DateTime('now'));
  128.         }
  129.         return $this;
  130.     }
  131.     public function getDeletedAt(): ?\DateTimeInterface
  132.     {
  133.         return $this->deletedAt;
  134.     }
  135.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  136.     {
  137.         $this->deletedAt $deletedAt;
  138.         return $this;
  139.     }
  140.     public function getUpdatedAt(): ?\DateTimeInterface
  141.     {
  142.         return $this->updatedAt;
  143.     }
  144.     public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  145.     {
  146.         $this->updatedAt $updatedAt;
  147.         return $this;
  148.     }
  149.     public function getCreatedAt(): ?\DateTimeInterface
  150.     {
  151.         return $this->createdAt;
  152.     }
  153.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  154.     {
  155.         $this->createdAt $createdAt;
  156.         return $this;
  157.     }
  158.     /**
  159.      * @return Collection|Reloj[]
  160.      */
  161.     public function getRelojes(): Collection
  162.     {
  163.         return $this->relojes;
  164.     }
  165.     public function addReloje(Reloj $reloje): self
  166.     {
  167.         if (!$this->relojes->contains($reloje)) {
  168.             $this->relojes[] = $reloje;
  169.             $reloje->setMarca($this);
  170.         }
  171.         return $this;
  172.     }
  173.     public function removeReloje(Reloj $reloje): self
  174.     {
  175.         if ($this->relojes->removeElement($reloje)) {
  176.             // set the owning side to null (unless already changed)
  177.             if ($reloje->getMarca() === $this) {
  178.                 $reloje->setMarca(null);
  179.             }
  180.         }
  181.         return $this;
  182.     }
  183.     /**
  184.      * @return Collection|ValoracionesRelojes[]
  185.      */
  186.     public function getValoracionesRelojes(): Collection
  187.     {
  188.         return $this->valoracionesRelojes;
  189.     }
  190.     public function addValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
  191.     {
  192.         if (!$this->valoracionesRelojes->contains($valoracionesReloje)) {
  193.             $this->valoracionesRelojes[] = $valoracionesReloje;
  194.             $valoracionesReloje->setMarca($this);
  195.         }
  196.         return $this;
  197.     }
  198.     public function removeValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
  199.     {
  200.         if ($this->valoracionesRelojes->removeElement($valoracionesReloje)) {
  201.             // set the owning side to null (unless already changed)
  202.             if ($valoracionesReloje->getMarca() === $this) {
  203.                 $valoracionesReloje->setMarca(null);
  204.             }
  205.         }
  206.         return $this;
  207.     }
  208.     /**
  209.      * @return Collection<int, DetalleOperacion>
  210.      */
  211.     public function getDetalleOperaciones(): Collection
  212.     {
  213.         return $this->detalleOperaciones;
  214.     }
  215.     public function addDetalleOperacione(DetalleOperacion $detalleOperacione): self
  216.     {
  217.         if (!$this->detalleOperaciones->contains($detalleOperacione)) {
  218.             $this->detalleOperaciones->add($detalleOperacione);
  219.             $detalleOperacione->setMarca($this);
  220.         }
  221.         return $this;
  222.     }
  223.     public function removeDetalleOperacione(DetalleOperacion $detalleOperacione): self
  224.     {
  225.         if ($this->detalleOperaciones->removeElement($detalleOperacione)) {
  226.             // set the owning side to null (unless already changed)
  227.             if ($detalleOperacione->getMarca() === $this) {
  228.                 $detalleOperacione->setMarca(null);
  229.             }
  230.         }
  231.         return $this;
  232.     }
  233.     /**
  234.      * @return Collection<int, ActividadAbstract>
  235.      */
  236.     public function getActividades(): Collection
  237.     {
  238.         return $this->actividades;
  239.     }
  240.     public function addActividade(ActividadAbstract $actividade): static
  241.     {
  242.         if (!$this->actividades->contains($actividade)) {
  243.             $this->actividades->add($actividade);
  244.             $actividade->setRelojMarca($this);
  245.         }
  246.         return $this;
  247.     }
  248.     public function removeActividade(ActividadAbstract $actividade): static
  249.     {
  250.         if ($this->actividades->removeElement($actividade)) {
  251.             // set the owning side to null (unless already changed)
  252.             if ($actividade->getRelojMarca() === $this) {
  253.                 $actividade->setRelojMarca(null);
  254.             }
  255.         }
  256.         return $this;
  257.     }
  258. }