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