src/Entity/Creditos.php line 9

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CreditosRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. #[ORM\Entity(repositoryClassCreditosRepository::class)]
  6. class Creditos
  7. {
  8.     const TP_COMPRA_CREDITOS    0;
  9.     const TP_PREMIO             1;
  10.     const TP_BONUS              2;
  11.     const TP_DIVERSOS           3;
  12.     const TP_CADASTRO           4;
  13.     const TP_DESCONTO           5;
  14.     const TP_CONFIG_INFO        6;
  15.     const VET_TP = [
  16.         self::TP_COMPRA_CREDITOS    => ['label' => 'Compra de créditos',    'img' => '/img/tesouro.gif',    'qtd' => 1500'sinal' => '+'],
  17.         self::TP_PREMIO             => ['label' => 'Prêmio',                'img' => '/img/rubi.gif',       'qtd' => 20'sinal' => '+'],
  18.         self::TP_BONUS              => ['label' => 'Bônus',                 'img' => '/img/estrela.gif',    'qtd' => 10'sinal' => '+'],
  19.         self::TP_DIVERSOS           => ['label' => 'Diversos',              'img' => '/img/moeda.gif',      'qtd' => 1'sinal' => '+'],        
  20.         self::TP_CADASTRO           => ['label' => 'Cadastro',              'img' => '/img/moeda.gif',      'qtd' => 50'sinal' => '+'],
  21.         self::TP_DESCONTO           => ['label' => 'Desconto',              'img' => '/img/moeda.gif',      'qtd' => 1'sinal' => '-'],
  22.         self::TP_CONFIG_INFO        => ['label' => 'Configurações',         'img' => '/img/moeda.gif',      'qtd' => 100'sinal' => '+'],
  23.     ];
  24.     
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column]
  28.     private ?int $id null;
  29.     #[ORM\Column(length255)]
  30.     private ?string $nome null;
  31.     #[ORM\Column]
  32.     private ?float $valor null;
  33.     #[ORM\Column]
  34.     private ?int $tipo null;
  35.     #[ORM\Column]
  36.     private ?\DateTimeImmutable $created_at null;
  37.     #[ORM\ManyToOne(inversedBy'Creditos')]
  38.     private ?User $User null;
  39.     public function getId(): ?int
  40.     {
  41.         return $this->id;
  42.     }
  43.     public function getNome(): ?string
  44.     {
  45.         return $this->nome;
  46.     }
  47.     public function setNome(string $nome): self
  48.     {
  49.         $this->nome $nome;
  50.         return $this;
  51.     }
  52.     public function getValor(): ?float
  53.     {
  54.         return $this->valor;
  55.     }
  56.     public function setValor(float $valor): self
  57.     {
  58.         $this->valor $valor;
  59.         return $this;
  60.     }
  61.     public function getTipo(): ?int
  62.     {
  63.         return $this->tipo;
  64.     }
  65.     
  66.     public function getTipoLabel()
  67.     {
  68.         return self::VET_TP[$this->tipo]['label'];
  69.     }
  70.     
  71.     public function getTipoImg()
  72.     {
  73.         return self::VET_TP[$this->tipo]['img'];
  74.     }
  75.     
  76.     public function getTipoSinal()
  77.     {
  78.         return self::VET_TP[$this->tipo]['sinal'];
  79.     }
  80.     public function setTipo(int $tipo): self
  81.     {
  82.         $this->tipo $tipo;
  83.         if(!isset(self::VET_TP[$tipo])){
  84.             throw new \Exception('Tipo de crédito não encontrado');
  85.         }
  86.         
  87.         return $this;
  88.     }
  89.     public function getCreatedAt(): ?\DateTimeImmutable
  90.     {
  91.         return $this->created_at;
  92.     }
  93.     public function setCreatedAt(): self
  94.     {
  95.         $this->created_at = new \DateTimeImmutable('now');
  96.         return $this;
  97.     }
  98.     public function getUser(): ?User
  99.     {
  100.         return $this->User;
  101.     }
  102.     public function setUser(?User $User): self
  103.     {
  104.         $this->User $User;
  105.         return $this;
  106.     }
  107. }