src/Entity/App/Banner.php line 25

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\DateRange;
  6. use DateTime;
  7. use DateTimeZone;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  11. use Gedmo\Timestampable\Traits\TimestampableEntity;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Banner
  15.  *
  16.  *@ORM\Entity(repositoryClass="App\Repository\App\BannerRepository")
  17.  * @ORM\HasLifecycleCallbacks()
  18.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
  19.  * @DateRange()
  20.  */
  21. class Banner
  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.      * @ORM\Column(type="string", name="tipo_banner", length=255)
  32.      * @Assert\NotBlank(message="El valor es requerido")
  33.      * @Assert\Length(
  34.      *       max = 255,
  35.      *       maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  36.      *  )
  37.      */
  38.     private string $tipoBanner;
  39.     /**
  40.      * @var string|null
  41.      * @ORM\Column(type="string", name="descripcion_banner")
  42.      * @ORM\Column(type="string", nullable=true)
  43.      * @Assert\Length(
  44.      *  max = 5000,
  45.      *  maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  46.      *  )
  47.      */
  48.     private ?string $descripcion null;
  49.     /**
  50.      * @ORM\Column(type="string", name="ubicacion_banner", length=255)
  51.      * @Assert\NotBlank(message="El valor es requerido")
  52.      * @Assert\Length(
  53.      *        max = 255,
  54.      *        maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  55.      *   )
  56.      */
  57.     private string $ubicacion;
  58.     /**
  59.      * @ORM\Column(type="string", name="color_banner", length=50)
  60.      * @Assert\NotBlank(message="El valor es requerido")
  61.      * @Assert\Length(
  62.      *         max = 50,
  63.      *         maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  64.      *    )
  65.      */
  66.     private string $color;
  67.     /**
  68.      * @ORM\Column(type="string", name="icono_banner", length=255)
  69.      * @Assert\Length(
  70.      *         max = 255,
  71.      *         maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  72.      *    )
  73.      */
  74.     private ?string $icono;
  75.     /**
  76.      * @var string|null
  77.      * @ORM\Column(type="string", name="texto_boton_principal", length=255, nullable= true)
  78.      * @Assert\Length(
  79.      *          max = 255,
  80.      *          maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  81.      *     )
  82.      */
  83.     private ?string $textoBotonPrincipal null;
  84.     /**
  85.      * @var string|null
  86.      * @ORM\Column(type="string", name="enlace_boton_principal", length=255, nullable= true)
  87.      * @Assert\Length(
  88.      * max = 255,
  89.      * maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  90.      * )
  91.      */
  92.     private ?string $enlaceBotonPrincipal null;
  93.     /**
  94.      * @var string|null
  95.      * @ORM\Column(type="string", name="texto_boton_secundario", length=255, nullable= true)
  96.      * @Assert\Length(
  97.      * max = 255,
  98.      * maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  99.      * )
  100.      */
  101.     private ?string $textoBotonSecundario null;
  102.     /**
  103.      * @var string|null
  104.      * @ORM\Column(type="string", name="enlace_boton_secundario", length=255, nullable= true)
  105.      * @Assert\Length(
  106.      * max = 255,
  107.      * maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  108.      * )
  109.      */
  110.     private ?string $enlaceBotonSecundario null;
  111.     /**
  112.      * @var DateTime|null
  113.      * @ORM\Column(type="datetime")
  114.      * @Assert\NotNull(message="El valor es requerido")
  115.      */
  116.     private ?DateTime $fechaInicio null;
  117.     /**
  118.      * @var DateTime|null
  119.      * @ORM\Column(type="datetime")
  120.      * @Assert\NotNull(message="El valor es requerido")
  121.      */
  122.     private ?DateTime $fechaFin null;
  123.     /**
  124.      * @var string|null
  125.      * @ORM\Column(type="string", nullable= true)
  126.      * @Assert\Length(
  127.      *  max = 255,
  128.      *  maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  129.      *  )
  130.      */
  131.     private ?string $tipoAlerta null;
  132.     /**
  133.      * @var string|null
  134.      * @ORM\Column(type="string", nullable=true)
  135.      * @Assert\Length(
  136.      *  max = 5000,
  137.      *  maxMessage = "La cantidad maxima es {{ limit }} caracteres"
  138.      *  )
  139.      */
  140.     private ?string $descripcionAlerta null;
  141.     /**
  142.      * @var bool
  143.      * @ORM\Column(type="boolean")
  144.      */
  145.     private bool $activoAlerta false;
  146.     /**
  147.      * @var DateTime|null
  148.      *@ORM\Column(type="datetime", nullable=true)
  149.      */
  150.     private ?DateTime $fechaInicioAlerta null;
  151.     /**
  152.      * @var DateTime|null
  153.      * *@ORM\Column(type="datetime", nullable=true)
  154.      */
  155.     private ?DateTime $fechaFinAlerta null;
  156.     public function getId(): ?int
  157.     {
  158.         return $this->id;
  159.     }
  160.     public function setId(?int $id): void
  161.     {
  162.         $this->id $id;
  163.     }
  164.     public function getTipoBannerForTable(): string
  165.     {
  166.         return '<span class="badge badge-secondary badge-lighten">  ' $this->tipoBanner ' </span>' ;
  167.     }
  168.     public function getTipoBanner(): string
  169.     {
  170.         return $this->tipoBanner;
  171.     }
  172.     public function setTipoBanner(string $tipoBanner): void
  173.     {
  174.         $this->tipoBanner $tipoBanner;
  175.     }
  176.     public function getDescripcion(): ?string
  177.     {
  178.         return $this->descripcion;
  179.     }
  180.     public function setDescripcion(?string $descripcion): void
  181.     {
  182.         $this->descripcion $descripcion;
  183.     }
  184.     public function getUbicacion(): string
  185.     {
  186.         return $this->ubicacion;
  187.     }
  188.     public function setUbicacion(string $ubicacion): void
  189.     {
  190.         $this->ubicacion $ubicacion;
  191.     }
  192.     public function getColorForTable(): string
  193.     {
  194.         //Aqui esta el error
  195.         // $color = $this->color === 'Claro' ? "badge badge-secondary badge-lighten" : "badge badge-secondary";
  196.         // return '<span class=" '.$color.'">  ' . $this->color . ' </span>' ;
  197.         return '<span class="badge badge-secondary badge-lighten"> ' $this->color ' </span>' ;
  198.     }
  199.     public function getColor(): string
  200.     {
  201.         return $this->color;
  202.     }
  203.     public function setColor(string $color): void
  204.     {
  205.         $this->color $color;
  206.     }
  207.     public function getIcono(): ?string
  208.     {
  209.         return $this->icono;
  210.     }
  211.     public function setIcono(?string $icono): void
  212.     {
  213.         $this->icono $icono;
  214.     }
  215.     public function getTextoBotonPrincipal(): ?string
  216.     {
  217.         return $this->textoBotonPrincipal;
  218.     }
  219.     public function setTextoBotonPrincipal(?string $textoBotonPrincipal): void
  220.     {
  221.         $this->textoBotonPrincipal $textoBotonPrincipal;
  222.     }
  223.     public function getEnlaceBotonPrincipal(): ?string
  224.     {
  225.         return $this->enlaceBotonPrincipal;
  226.     }
  227.     public function setEnlaceBotonPrincipal(?string $enlaceBotonPrincipal): void
  228.     {
  229.         $this->enlaceBotonPrincipal $enlaceBotonPrincipal;
  230.     }
  231.     public function getTextoBotonSecundario(): ?string
  232.     {
  233.         return $this->textoBotonSecundario;
  234.     }
  235.     public function setTextoBotonSecundario(?string $textoBotonSecundario): void
  236.     {
  237.         $this->textoBotonSecundario $textoBotonSecundario;
  238.     }
  239.     public function getEnlaceBotonSecundario(): ?string
  240.     {
  241.         return $this->enlaceBotonSecundario;
  242.     }
  243.     public function setEnlaceBotonSecundario(?string $enlaceBotonSecundario): void
  244.     {
  245.         $this->enlaceBotonSecundario $enlaceBotonSecundario;
  246.     }
  247.     public function getFechaInicio(): ?DateTime
  248.     {
  249.         if ($this->fechaInicio === null) {
  250.             return null;
  251.         }
  252.         return new DateTime($this->fechaInicio->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  253.     }
  254.     public function setFechaInicio(?DateTime $fechaInicio): void
  255.     {
  256.         $this->fechaInicio $fechaInicio;
  257.         if ($fechaInicio !== null){
  258.             $this->fechaInicio = new DateTime($fechaInicio->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  259.         }
  260.     }
  261.     public function getFechaFin(): ?DateTime
  262.     {
  263.         if ($this->fechaFin === null) {
  264.             return null;
  265.         }
  266.         return new DateTime($this->fechaFin->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  267.     }
  268.     public function setFechaFin(?DateTime $fechaFin): void
  269.     {
  270.         $this->fechaFin $fechaFin;
  271.         if ($fechaFin !== null){
  272.             $this->fechaFin = new DateTime($fechaFin->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  273.         }
  274.     }
  275.     public function getTipoAlerta(): ?string
  276.     {
  277.         return $this->tipoAlerta;
  278.     }
  279.     public function setTipoAlerta(?string $tipoAlerta): void
  280.     {
  281.         $this->tipoAlerta $tipoAlerta;
  282.     }
  283.     public function getDescripcionAlerta(): ?string
  284.     {
  285.         return $this->descripcionAlerta;
  286.     }
  287.     public function setDescripcionAlerta(?string $descripcionAlerta): void
  288.     {
  289.         $this->descripcionAlerta $descripcionAlerta;
  290.     }
  291.     public function isActivoAlerta(): bool
  292.     {
  293.         return $this->activoAlerta;
  294.     }
  295.     public function setActivoAlerta(bool $activoAlerta): void
  296.     {
  297.         $this->activoAlerta $activoAlerta;
  298.     }
  299.     public function getFechaInicioAlerta(): ?DateTime
  300.     {
  301.         if ($this->fechaInicioAlerta === null) {
  302.             return null;
  303.         }
  304.         return new DateTime($this->fechaInicioAlerta->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  305.     }
  306.     public function setFechaInicioAlerta(?DateTime $fechaInicioAlerta): void
  307.     {
  308.         $this->fechaInicioAlerta $fechaInicioAlerta;
  309.         if ($fechaInicioAlerta !== null){
  310.             $this->fechaInicioAlerta = new DateTime($fechaInicioAlerta->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  311.         }
  312.     }
  313.     public function getFechaFinAlerta(): ?DateTime
  314.     {
  315.         if ($this->fechaFinAlerta === null) {
  316.             return null;
  317.         }
  318.         return new DateTime($this->fechaFinAlerta->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  319.     }
  320.     public function setFechaFinAlerta(?DateTime $fechaFinAlerta): void
  321.     {
  322.         $this->fechaFinAlerta $fechaFinAlerta;
  323.         if ($fechaFinAlerta !== null){
  324.             $this->fechaFinAlerta = new DateTime($fechaFinAlerta->format("Y-m-d H:i:s"), new DateTimeZone('America/Argentina/Buenos_Aires'));
  325.         }
  326.     }
  327.     public function getClassCssAlerta()
  328.     {
  329.         $tiposAlerta = [
  330.             'Información' => 'badge badge-info badge-lighten',
  331.             'Peligro' => 'badge badge-danger badge-lighten',
  332.             'Advertencia' => 'badge badge-warning badge-lighten',
  333.             'OK' => 'badge badge-success badge-lighten'
  334.         ];
  335.         $claseCssAlerta '<span class="badge text-default"></span>';
  336.         if (array_key_exists($this->tipoAlerta$tiposAlerta)){
  337.             $claseCssAlerta =  '<span class="badge '$tiposAlerta[$this->tipoAlerta] .' mr-2">' $this->getTipoAlerta() . '</span>' ;
  338.         }
  339.         return $claseCssAlerta;
  340.     }
  341.     use ActivoTrait;
  342.     use PosicionTrait;
  343.     use TimestampableEntity;
  344.     use SoftDeleteableEntity;
  345. }