src/Entity/Marca.php line 22

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