<?php
namespace App\Entity\App;
use App\Utils\Traits\ActivoTrait;
use App\Utils\Traits\PosicionTrait;
use App\Validator\Constraints\Seccion\SeccionConstraints;
use DateTime;
use DateTimeZone;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\App\SeccionRepository")
* @ORM\HasLifecycleCallbacks()
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
* @SeccionConstraints()
*/
class Seccion
{
/**
* @var integer|null
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @var string|null
* @ORM\Column(type="string", name="titulo")
* @ORM\Column(type="string", nullable=false)
* @Assert\Length(
* max = 5000,
* maxMessage = "La cantidad maxima es {{ limit }} caracteres"
* )
*/
private ?string $titulo;
/**
* @var string|null
* @ORM\Column(type="string", name="descripcion")
* @ORM\Column(type="string", nullable=true)
* @Assert\Length(
* max = 5000,
* maxMessage = "La cantidad maxima es {{ limit }} caracteres"
* )
*/
private ?string $descripcion = null;
/**
* @var DateTime|null
* @ORM\Column(type="datetime")
* @Assert\NotNull(message="El valor es requerido")
*/
private ?DateTime $fechaInicio = null;
/**
* @var DateTime|null
* @ORM\Column(type="datetime")
* @Assert\NotNull(message="El valor es requerido")
*/
private ?DateTime $fechaFin = null;
/**
* @ORM\OneToMany(targetEntity="App\Entity\App\Tarjeta", mappedBy="seccion", cascade={"persist", "remove"})
*/
private $tarjetas;
public function __construct()
{
$this->tarjetas = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function setId(?int $id): void
{
$this->id = $id;
}
public function getTitulo(): ?string
{
return $this->titulo;
}
public function setTitulo(?string $titulo): void
{
$this->titulo = $titulo;
}
public function getDescripcion(): ?string
{
return $this->descripcion;
}
public function setDescripcion(?string $descripcion): void
{
$this->descripcion = $descripcion;
}
public function getFechaInicio(): ?DateTime
{
if ($this->fechaInicio === null) {
return null;
}
return new DateTime($this->fechaInicio->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
}
public function setFechaInicio(?DateTime $fechaInicio): void
{
$this->fechaInicio = $fechaInicio;
if ($fechaInicio !== null){
$this->fechaInicio = new DateTime($fechaInicio->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
}
}
public function getFechaFin(): ?DateTime
{
if ($this->fechaFin === null) {
return null;
}
return new DateTime($this->fechaFin->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
}
public function setFechaFin(?DateTime $fechaFin): void
{
$this->fechaFin = $fechaFin;
if ($fechaFin !== null){
$this->fechaFin = new DateTime($fechaFin->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
}
}
public function getTarjetas(): Collection
{
return $this->tarjetas;
}
public function addTarjeta(Tarjeta $tarjeta): self
{
if (!$this->tarjetas->contains($tarjeta)) {
$this->tarjetas[] = $tarjeta;
$tarjeta->setSeccion($this);
}
return $this;
}
public function removeTarjeta(Tarjeta $tarjeta): self
{
if ($this->tarjetas->removeElement($tarjeta)) {
if ($tarjeta->getSeccion() === $this) {
$tarjeta->setSeccion(null);
}
}
return $this;
}
public function getCantidadTarjetas(): int
{
return $this->tarjetas->count();
}
use ActivoTrait;
use PosicionTrait;
use TimestampableEntity;
use SoftDeleteableEntity;
}