<?php
namespace App\Entity;
use App\Repository\TicketsRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ORM\Mapping as ORM;
use Endroid\QrCode\Builder\Builder;
/**
* @ORM\Entity(repositoryClass=TicketsRepository::class)
* @ORM\Table(name="tickets")
* @ApiResource(attributes={
* "normalization_context"={"groups"={"read"}},
* "denormalization_context"={"groups"={"write"}}
* })
*
*/
class Ticket
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
*/
private $event_name;
/**
* @ORM\Column(type="string", length=255)
*/
private $session_name;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $session_date;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ticket_access;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ticket_sector;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ticket_row;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ticket_seat;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ticket_qr;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $value_qr;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="tickets")
* @Groups("read")
*/
private $user;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $status;
/**
* @ORM\Column(type="integer")
*/
private $idTicket;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $venue_adress;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $venue_city;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $code;
public function getId(): ?int
{
return $this->id;
}
public function getEventName(): ?string
{
return $this->event_name;
}
public function setEventName(?string $event_name): self
{
$this->event_name = $event_name;
return $this;
}
public function getSessionName(): ?string
{
return $this->session_name;
}
public function setSessionName(string $session_name): self
{
$this->session_name = $session_name;
return $this;
}
public function getSessionDate(): ?\DateTimeInterface
{
return $this->session_date;
}
public function setSessionDate(?\DateTimeInterface $session_date): self
{
$this->session_date = $session_date;
return $this;
}
public function getTicketAccess(): ?string
{
return $this->ticket_access;
}
public function setTicketAccess(?string $ticket_access): self
{
$this->ticket_access = $ticket_access;
return $this;
}
public function getTicketSector(): ?string
{
return $this->ticket_sector;
}
public function setTicketSector(?string $ticket_sector): self
{
$this->ticket_sector = $ticket_sector;
return $this;
}
public function getTicketRow(): ?string
{
return $this->ticket_row;
}
public function setTicketRow(?string $ticket_row): self
{
$this->ticket_row = $ticket_row;
return $this;
}
public function getTicketSeat(): ?string
{
return $this->ticket_seat;
}
public function setTicketSeat(?string $ticket_seat): self
{
$this->ticket_seat = $ticket_seat;
return $this;
}
public function getTicketQr(): ?string
{
return $this->createQR($this->ticket_qr);
}
public function setTicketQr(?string $ticket_qr): self
{
$this->ticket_qr = $ticket_qr;
return $this;
}
public function getValueQr(): ?string
{
return $this->value_qr;
}
public function setValueQr(?string $value_qr): self
{
$this->value_qr = $value_qr;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getStatus(): ?string
{
return $this->status;
}
public function setStatus(?string $status): self
{
$this->status = $status;
return $this;
}
public function getIdTicket(): ?int
{
return $this->idTicket;
}
public function setIdTicket(int $idTicket): self
{
$this->idTicket = $idTicket;
return $this;
}
public function getVenueAdress(): ?string
{
return $this->venue_adress;
}
public function setVenueAdress(?string $venue_adress): self
{
$this->venue_adress = $venue_adress;
return $this;
}
public function getVenueCity(): ?string
{
return $this->venue_city;
}
public function setVenueCity(?string $venue_city): self
{
$this->venue_city = $venue_city;
return $this;
}
public function createQR($value): string
{
$qr = Builder::create()
->data($value)
->build();
return base64_encode($qr->getString());
}
/**
* @return string|null
*/
public function getCode(): ?string
{
return $this->code;
}
/**
* @param string|null $code
*/
public function setCode(?string $code): void
{
$this->code = $code;
}
}