<?php
namespace App\Entity;
use App\Repository\ProyectoRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProyectoRepository::class)]
class Proyecto
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
// === DATOS BÁSICOS ===
#[ORM\Column(length: 255)]
private ?string $nombre = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $descripcion = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $ubicacion = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $estado = null;
// === FECHAS ===
#[ORM\Column(type: 'datetime', options: ['default' => 'CURRENT_TIMESTAMP'])]
private ?\DateTimeInterface $fechaCreacion = null;
#[ORM\Column(type: 'date', nullable: true)]
private ?\DateTimeInterface $fechaInicio = null;
#[ORM\Column(type: 'date', nullable: true)]
private ?\DateTimeInterface $fechaTermino = null;
// === RELACIONES ===
#[ORM\ManyToOne(targetEntity: Mandante::class)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?Mandante $mandante = null;
#[ORM\ManyToOne(targetEntity: SuperMandante::class)]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?SuperMandante $superMandante = null;
#[ORM\ManyToMany(targetEntity: Camara::class)]
#[ORM\JoinTable(name: 'proyecto_camaras')]
private Collection $camaras;
#[ORM\Column(options: ['default' => true])]
private ?bool $activo = true;
public function __construct()
{
$this->camaras = new ArrayCollection();
$this->fechaCreacion = new \DateTime(); // se setea automáticamente al crear
}
// === GETTERS & SETTERS ===
public function getId(): ?int
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): static
{
$this->nombre = $nombre;
return $this;
}
public function getDescripcion(): ?string
{
return $this->descripcion;
}
public function setDescripcion(?string $descripcion): static
{
$this->descripcion = $descripcion;
return $this;
}
public function getUbicacion(): ?string
{
return $this->ubicacion;
}
public function setUbicacion(?string $ubicacion): static
{
$this->ubicacion = $ubicacion;
return $this;
}
public function getEstado(): ?string
{
return $this->estado;
}
public function setEstado(?string $estado): static
{
$this->estado = $estado;
return $this;
}
public function getFechaCreacion(): ?\DateTimeInterface
{
return $this->fechaCreacion;
}
public function setFechaCreacion(\DateTimeInterface $fechaCreacion): static
{
$this->fechaCreacion = $fechaCreacion;
return $this;
}
public function getFechaInicio(): ?\DateTimeInterface
{
return $this->fechaInicio;
}
public function setFechaInicio(?\DateTimeInterface $fechaInicio): static
{
$this->fechaInicio = $fechaInicio;
return $this;
}
public function getFechaTermino(): ?\DateTimeInterface
{
return $this->fechaTermino;
}
public function setFechaTermino(?\DateTimeInterface $fechaTermino): static
{
$this->fechaTermino = $fechaTermino;
return $this;
}
public function getMandante(): ?Mandante
{
return $this->mandante;
}
public function setMandante(?Mandante $mandante): static
{
$this->mandante = $mandante;
return $this;
}
public function getSuperMandante(): ?SuperMandante
{
return $this->superMandante;
}
public function setSuperMandante(?SuperMandante $superMandante): static
{
$this->superMandante = $superMandante;
return $this;
}
/**
* @return Collection<int, Camara>
*/
public function getCamaras(): Collection
{
return $this->camaras;
}
public function addCamara(Camara $camara): static
{
if (!$this->camaras->contains($camara)) {
$this->camaras->add($camara);
}
return $this;
}
public function removeCamara(Camara $camara): static
{
$this->camaras->removeElement($camara);
return $this;
}
public function isActivo(): ?bool
{
return $this->activo;
}
public function setActivo(bool $activo): static
{
$this->activo = $activo;
return $this;
}
}