<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass="App\Repository\MarcaRepository")
* @ORM\Table(name="marca", schema="perseo")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
* @Vich\Uploadable
* @UniqueEntity("nombre")
*/
class Marca
{
/**
* @ORM\Id
* @ORM\Column(type="bigint", options={"unsigned":true})
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", nullable=false)
*/
protected $nombre;
/**
* @ORM\Column(type="string", nullable=true)
*/
protected $logo;
/** @Vich\UploadableField(mapping="marca", fileNameProperty="logo")
* @var File
*/
protected $logoFile;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
protected $deletedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Reloj", mappedBy="marca")
*/
protected $relojes;
/**
* @ORM\OneToMany(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="relojMarca")
*/
private $actividades;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ValoracionesRelojes", mappedBy="relojMarca")
*/
protected $valoracionesRelojes;
/**
* @ORM\OneToMany(targetEntity="App\Entity\DetalleOperacion", mappedBy="marca")
*/
protected $detalleOperaciones;
public function __construct()
{
$this->relojes = new ArrayCollection();
$this->valoracionesRelojes = new ArrayCollection();
$this->detalleOperaciones = new ArrayCollection();
$this->actividades = new ArrayCollection();
}
public function __toString(): string
{
return $this->getNombre();
}
public function getId(): ?string
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): self
{
$this->logo = $logo;
return $this;
}
public function getLogoFile(): ?File
{
return $this->logoFile;
}
public function setLogoFile(?File $logoFile): self
{
$this->logoFile = $logoFile;
if ($logoFile) {
// if 'updatedAt' is not defined in your entity, use another property
$this->setUpdatedAt(new \DateTime('now'));
}
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection|Reloj[]
*/
public function getRelojes(): Collection
{
return $this->relojes;
}
public function addReloje(Reloj $reloje): self
{
if (!$this->relojes->contains($reloje)) {
$this->relojes[] = $reloje;
$reloje->setMarca($this);
}
return $this;
}
public function removeReloje(Reloj $reloje): self
{
if ($this->relojes->removeElement($reloje)) {
// set the owning side to null (unless already changed)
if ($reloje->getMarca() === $this) {
$reloje->setMarca(null);
}
}
return $this;
}
/**
* @return Collection|ValoracionesRelojes[]
*/
public function getValoracionesRelojes(): Collection
{
return $this->valoracionesRelojes;
}
public function addValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
{
if (!$this->valoracionesRelojes->contains($valoracionesReloje)) {
$this->valoracionesRelojes[] = $valoracionesReloje;
$valoracionesReloje->setMarca($this);
}
return $this;
}
public function removeValoracionesReloje(ValoracionesRelojes $valoracionesReloje): self
{
if ($this->valoracionesRelojes->removeElement($valoracionesReloje)) {
// set the owning side to null (unless already changed)
if ($valoracionesReloje->getMarca() === $this) {
$valoracionesReloje->setMarca(null);
}
}
return $this;
}
/**
* @return Collection<int, DetalleOperacion>
*/
public function getDetalleOperaciones(): Collection
{
return $this->detalleOperaciones;
}
public function addDetalleOperacione(DetalleOperacion $detalleOperacione): self
{
if (!$this->detalleOperaciones->contains($detalleOperacione)) {
$this->detalleOperaciones->add($detalleOperacione);
$detalleOperacione->setMarca($this);
}
return $this;
}
public function removeDetalleOperacione(DetalleOperacion $detalleOperacione): self
{
if ($this->detalleOperaciones->removeElement($detalleOperacione)) {
// set the owning side to null (unless already changed)
if ($detalleOperacione->getMarca() === $this) {
$detalleOperacione->setMarca(null);
}
}
return $this;
}
/**
* @return Collection<int, ActividadAbstract>
*/
public function getActividades(): Collection
{
return $this->actividades;
}
public function addActividade(ActividadAbstract $actividade): static
{
if (!$this->actividades->contains($actividade)) {
$this->actividades->add($actividade);
$actividade->setRelojMarca($this);
}
return $this;
}
public function removeActividade(ActividadAbstract $actividade): static
{
if ($this->actividades->removeElement($actividade)) {
// set the owning side to null (unless already changed)
if ($actividade->getRelojMarca() === $this) {
$actividade->setRelojMarca(null);
}
}
return $this;
}
}