src/Entity/Palavra.php line 19

  1. <?php
  2. namespace App\Entity;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use App\Repository\PalavraRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\DBAL\Types\Types;
  9. /**
  10.  * @ORM\Entity
  11.  * @Gedmo\SoftDeleteable(fieldName="deleted_at", timeAware=false, hardDelete=false)
  12.  */
  13. #[ORM\Entity(repositoryClassPalavraRepository::class)]
  14. #[Gedmo\SoftDeleteable(fieldName'deleted_at'timeAwarefalsehardDeletefalse)]
  15. class Palavra
  16. {
  17.     #[ORM\Id]
  18.     #[ORM\GeneratedValue]
  19.     #[ORM\Column]
  20.     private ?int $id null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $palavra null;
  23.     
  24.     #[ORM\Column(length255)]
  25.     private ?string $palavracrua null;
  26.     #[ORM\Column]
  27.     private ?bool $ativo null;
  28.     
  29.     #[ORM\Column(typeTypes::INTEGERnullabletrue)]
  30.     private ?int $tamanho null;
  31.     
  32.     #[ORM\Column(length1)]
  33.     private ?string $inicial null;
  34.     #[ORM\ManyToMany(targetEntityCategoria::class, inversedBy'Palavras')]
  35.     private Collection $Categorias;
  36.     
  37.     #[ORM\Column(length255)]
  38.     private ?string $dica null;
  39.     
  40.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  41.     private ?\DateTimeInterface $created_at null;
  42.     
  43.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  44.     private ?\DateTimeInterface $updated_at null;
  45.     #[ORM\OneToMany(mappedBy'Palavra'targetEntityUserPalavras::class)]
  46.     private Collection $UserPalavras;
  47.     
  48.     #[ORM\Column]
  49.     private ?bool $nivel0 null;
  50.     #[ORM\Column]
  51.     private ?bool $nivel1 null;
  52.     #[ORM\Column]
  53.     private ?bool $nivel2 null;
  54.     #[ORM\Column]
  55.     private ?bool $nivel3 null;
  56.     #[ORM\Column]
  57.     private ?bool $nivel4 null;
  58.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  59.     private ?\DateTimeInterface $dtDicaChatgpt null;
  60.     #[ORM\Column(nullabletrue)]
  61.     private ?\DateTimeImmutable $deleted_at null;
  62.     #[ORM\OneToMany(mappedBy'teste'targetEntityJogos::class)]
  63.     private Collection $jogos;
  64.     public function __construct()
  65.     {
  66.         $this->Categorias = new ArrayCollection();
  67.         $this->UserPalavras = new ArrayCollection();
  68.         $this->jogos = new ArrayCollection();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getPalavra(): ?string
  75.     {
  76.         return $this->palavra;
  77.     }
  78.     public function setPalavra(string $palavra): self
  79.     {
  80.         $this->palavra $palavra;
  81.         return $this;
  82.     }
  83.     
  84.     public function getPalavracrua(): ?string
  85.     {
  86.         return $this->palavracrua;
  87.     }
  88.     public function setPalavracrua(string $palavra): self
  89.     {
  90.         $this->palavracrua $palavra;
  91.         return $this;
  92.     }
  93.     public function isAtivo(): ?bool
  94.     {
  95.         return $this->ativo;
  96.     }
  97.     public function setAtivo(bool $ativo): self
  98.     {
  99.         $this->ativo $ativo;
  100.         return $this;
  101.     }
  102.     
  103.     public function getTamanho(): ?int
  104.     {
  105.         return $this->tamanho;
  106.     }
  107.     
  108.     public function setTamanho(int $tamanho): self
  109.     {
  110.         $this->tamanho $tamanho;
  111.         
  112.         return $this;
  113.     }
  114.     public function getInicial(): ?string
  115.     {
  116.         return $this->inicial;
  117.     }   
  118.     
  119.     public function setInicial(string $inicial): self
  120.     {
  121.         $this->inicial $inicial;
  122.         
  123.         return $this;
  124.     }    
  125.     
  126.     /**
  127.      * @return Collection<int, Categorias>
  128.      */
  129.     public function getCategorias(): Collection
  130.     {
  131.         return $this->Categorias;
  132.     }
  133.     public function addCategoria(Categoria $categoria): self
  134.     {
  135.         if (!$this->Categorias->contains($categoria)) {
  136.             $this->Categorias->add($categoria);
  137.         }
  138.         return $this;
  139.     }
  140.     public function removeCategoria(Categoria $categoria): self
  141.     {
  142.         $this->Categorias->removeElement($categoria);
  143.         return $this;
  144.     }
  145.     
  146.     public function clearCategoria(\Doctrine\ORM\EntityManager $em): self
  147.     {
  148.         $vetCategorias $this->getCategorias();
  149.         foreach($vetCategorias as $categoria){
  150.             $this->removeCategoria($categoria);
  151.         }
  152.         $em->persist($this);
  153.         $em->flush();
  154.         return $this;
  155.     }
  156.     
  157.     public function getDica(): ?string
  158.     {
  159.         return $this->dica;
  160.     }
  161.     public function setDica(string $dica): self
  162.     {
  163.         $this->dica $dica;
  164.         return $this;
  165.     }
  166.     
  167.     public function getCreatedAt(): ?\DateTimeInterface
  168.     {
  169.         return $this->created_at;
  170.     }
  171.     public function setCreatedAt(): self
  172.     {
  173.         $this->created_at = new \DateTime('now');
  174.         return $this;
  175.     }
  176.     
  177.     public function getUpdatedAt(): ?\DateTimeInterface
  178.     {
  179.         return $this->updated_at;
  180.     }
  181.     public function setUpdatedAt(): self
  182.     {
  183.         $this->updated_at = new \DateTime('now');
  184.         return $this;
  185.     }
  186.     /**
  187.      * @return Collection<int, UserPalavras>
  188.      */
  189.     public function getUserPalavras(): Collection
  190.     {
  191.         return $this->UserPalavras;
  192.     }
  193.     public function addUserPalavra(UserPalavras $userPalavra): self
  194.     {
  195.         if (!$this->UserPalavras->contains($userPalavra)) {
  196.             $this->UserPalavras->add($userPalavra);
  197.             $userPalavra->setPalavra($this);
  198.         }
  199.         return $this;
  200.     }
  201.     public function removeUserPalavra(UserPalavras $userPalavra): self
  202.     {
  203.         if ($this->UserPalavras->removeElement($userPalavra)) {
  204.             // set the owning side to null (unless already changed)
  205.             if ($userPalavra->getPalavra() === $this) {
  206.                 $userPalavra->setPalavra(null);
  207.             }
  208.         }
  209.         return $this;
  210.     }
  211.     public function isNivel0(): ?bool
  212.     {
  213.         return $this->nivel0;
  214.     }
  215.     public function setNivel0(bool $nivel0): self
  216.     {
  217.         $this->nivel0 $nivel0;
  218.         return $this;
  219.     }
  220.     public function isNivel1(): ?bool
  221.     {
  222.         return $this->nivel1;
  223.     }
  224.     public function setNivel1(bool $nivel1): self
  225.     {
  226.         $this->nivel1 $nivel1;
  227.         return $this;
  228.     }
  229.     public function isNivel2(): ?bool
  230.     {
  231.         return $this->nivel2;
  232.     }
  233.     public function setNivel2(bool $nivel2): self
  234.     {
  235.         $this->nivel2 $nivel2;
  236.         return $this;
  237.     }
  238.     public function isNivel3(): ?bool
  239.     {
  240.         return $this->nivel3;
  241.     }
  242.     public function setNivel3(bool $nivel3): self
  243.     {
  244.         $this->nivel3 $nivel3;
  245.         return $this;
  246.     }
  247.     public function isNivel4(): ?bool
  248.     {
  249.         return $this->nivel4;
  250.     }
  251.     public function setNivel4(bool $nivel4): self
  252.     {
  253.         $this->nivel4 $nivel4;
  254.         return $this;
  255.     }
  256.     
  257.     public function resetNiveis(): self
  258.     {
  259.         $this->nivel0 false;
  260.         $this->nivel1 false;
  261.         $this->nivel2 false;
  262.         $this->nivel3 false;
  263.         $this->nivel4 false;        
  264.         
  265.         return $this;
  266.     }
  267.     
  268.     public function getNiveis()
  269.     {
  270.         $r = [];
  271.         if($this->isNivel0()){
  272.             $r[] = \App\Util\Niveis::getNivelByKey(0);
  273.         }
  274.         
  275.         if($this->isNivel1()){
  276.             $r[] = \App\Util\Niveis::getNivelByKey(1);
  277.         }
  278.         
  279.         if($this->isNivel2()){
  280.             $r[] = \App\Util\Niveis::getNivelByKey(2);
  281.         }
  282.         
  283.         if($this->isNivel3()){
  284.             $r[] = \App\Util\Niveis::getNivelByKey(3);
  285.         }
  286.         
  287.         if($this->isNivel4()){
  288.             $r[] = \App\Util\Niveis::getNivelByKey(4);
  289.         }
  290.         
  291.         return $r;
  292.     }
  293.     public function getDtDicaChatgpt(): ?\DateTimeInterface
  294.     {
  295.         return $this->dtDicaChatgpt;
  296.     }
  297.     public function setDtDicaChatgpt(): self
  298.     {
  299.         $this->dtDicaChatgpt = new \DateTime('now');
  300.         return $this;
  301.     }
  302.     public function getDeletedAt(): ?\DateTimeImmutable
  303.     {
  304.         return $this->deleted_at;
  305.     }
  306.     public function setDeletedAt(\DateTimeImmutable $deleted_at): self
  307.     {
  308.         $this->deleted_at $deleted_at;
  309.         return $this;
  310.     }
  311.     /**
  312.      * @return Collection<int, Jogos>
  313.      */
  314.     public function getJogos(): Collection
  315.     {
  316.         return $this->jogos;
  317.     }
  318.     public function addJogo(Jogos $jogo): static
  319.     {
  320.         if (!$this->jogos->contains($jogo)) {
  321.             $this->jogos->add($jogo);
  322.             $jogo->setTeste($this);
  323.         }
  324.         return $this;
  325.     }
  326.     public function removeJogo(Jogos $jogo): static
  327.     {
  328.         if ($this->jogos->removeElement($jogo)) {
  329.             // set the owning side to null (unless already changed)
  330.             if ($jogo->getTeste() === $this) {
  331.                 $jogo->setTeste(null);
  332.             }
  333.         }
  334.         return $this;
  335.     }
  336. }