src/Entity/App/Seccion.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\App;
  3. use App\Utils\Traits\ActivoTrait;
  4. use App\Utils\Traits\PosicionTrait;
  5. use App\Validator\Constraints\Seccion\SeccionConstraints;
  6. use DateTime;
  7. use DateTimeZone;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Gedmo\Mapping\Annotation as Gedmo;
  12. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  13. use Gedmo\Timestampable\Traits\TimestampableEntity;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. /**
  16.  * @ORM\Entity(repositoryClass="App\Repository\App\SeccionRepository")
  17.  * @ORM\HasLifecycleCallbacks()
  18.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  19.  * @SeccionConstraints()
  20.  */
  21. class Seccion
  22. {
  23.     /**
  24.      * @var integer|null
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      * @ORM\Column(type="integer")
  28.      */
  29.     private $id;
  30.     /**
  31.      * @var string|null
  32.      * @ORM\Column(type="string", name="titulo")
  33.      * @ORM\Column(type="string", nullable=false)
  34.      * @Assert\Length(
  35.      *  max = 5000,
  36.      *  maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  37.      *  )
  38.      */
  39.     private ?string $titulo;
  40.     /**
  41.      * @var string|null
  42.      * @ORM\Column(type="string", name="descripcion")
  43.      * @ORM\Column(type="string", nullable=true)
  44.      * @Assert\Length(
  45.      *  max = 5000,
  46.      *  maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  47.      *  )
  48.      */
  49.     private ?string $descripcion null;
  50.     /**
  51.      * @var DateTime|null
  52.      * @ORM\Column(type="datetime")
  53.      * @Assert\NotNull(message="El valor es requerido")
  54.      */
  55.     private ?DateTime $fechaInicio null;
  56.     /**
  57.      * @var DateTime|null
  58.      * @ORM\Column(type="datetime")
  59.      * @Assert\NotNull(message="El valor es requerido")
  60.      */
  61.     private ?DateTime $fechaFin null;
  62.     /**
  63.      * @ORM\OneToMany(targetEntity="App\Entity\App\Tarjeta", mappedBy="seccion", cascade={"persist", "remove"})
  64.      */
  65.     private $tarjetas;
  66.     public function __construct()
  67.     {
  68.         $this->tarjetas = new ArrayCollection();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function setId(?int $id): void
  75.     {
  76.         $this->id $id;
  77.     }
  78.     public function getTitulo(): ?string
  79.     {
  80.         return $this->titulo;
  81.     }
  82.     public function setTitulo(?string $titulo): void
  83.     {
  84.         $this->titulo $titulo;
  85.     }
  86.     public function getDescripcion(): ?string
  87.     {
  88.         return $this->descripcion;
  89.     }
  90.     public function setDescripcion(?string $descripcion): void
  91.     {
  92.         $this->descripcion $descripcion;
  93.     }
  94.     public function getFechaInicio(): ?DateTime
  95.     {
  96.         if ($this->fechaInicio === null) {
  97.             return null;
  98.         }
  99.         return new DateTime($this->fechaInicio->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  100.     }
  101.     public function setFechaInicio(?DateTime $fechaInicio): void
  102.     {
  103.         $this->fechaInicio $fechaInicio;
  104.         if ($fechaInicio !== null){
  105.             $this->fechaInicio = new DateTime($fechaInicio->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  106.         }
  107.     }
  108.     public function getFechaFin(): ?DateTime
  109.     {
  110.         if ($this->fechaFin === null) {
  111.             return null;
  112.         }
  113.         return new DateTime($this->fechaFin->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  114.     }
  115.     public function setFechaFin(?DateTime $fechaFin): void
  116.     {
  117.         $this->fechaFin $fechaFin;
  118.         if ($fechaFin !== null){
  119.             $this->fechaFin = new DateTime($fechaFin->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  120.         }
  121.     }
  122.     public function getTarjetas(): Collection
  123.     {
  124.         return $this->tarjetas;
  125.     }
  126.     public function addTarjeta(Tarjeta $tarjeta): self
  127.     {
  128.         if (!$this->tarjetas->contains($tarjeta)) {
  129.             $this->tarjetas[] = $tarjeta;
  130.             $tarjeta->setSeccion($this);
  131.         }
  132.         return $this;
  133.     }
  134.     public function removeTarjeta(Tarjeta $tarjeta): self
  135.     {
  136.         if ($this->tarjetas->removeElement($tarjeta)) {
  137.             if ($tarjeta->getSeccion() === $this) {
  138.                 $tarjeta->setSeccion(null);
  139.             }
  140.         }
  141.         return $this;
  142.     }
  143.     public function getCantidadTarjetas(): int
  144.     {
  145.         return $this->tarjetas->count();
  146.     }
  147.     use ActivoTrait;
  148.     use PosicionTrait;
  149.     use TimestampableEntity;
  150.     use SoftDeleteableEntity;
  151. }