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