<?php
namespace App\Entity\Core;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Table('problem_dnd_bin')]
#[ORM\Entity]
class ProblemDndBin implements JsonSerializable, HasMediaInterface
{
use HasMediaTraits;
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $txt;
/**
* The index of the bin, starting at 1
*/
#[ORM\Column(name: 'binindex', type: 'smallint')]
private int $index;
#[ORM\JoinColumn(name: 'problem_dnd_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: ProblemDnd::class, inversedBy: 'bins')]
private ProblemDnd $problemDnd;
public function __construct()
{
$this->imageReference = null;
$this->audioReference = null;
}
public function getId(): int
{
return $this->id;
}
public function getTxt(): ?string
{
return $this->txt;
}
public function setTxt(?string $txt)
{
$this->txt = $txt;
}
public function getImg(): ?string
{
return $this->getImagePath();
}
public function getAudio(): ?string
{
return $this->getAudioPath();
}
public function getProblemDnd(): ProblemDnd
{
return $this->problemDnd;
}
public function setProblemDnd(ProblemDnd $problemDnd)
{
$this->problemDnd = $problemDnd;
}
public function getIndex(): int
{
return $this->index;
}
public function setIndex(int $index)
{
$this->index = $index;
}
public function jsonSerialize(): mixed
{
$txt = ($this->txt !== null && empty(trim($this->txt))) ? null : $this->txt;
return [
"id" => $this->id,
"idx" => $this->index,
"txt" => $txt,
"img" => $this->getImagePath(),
"audio" => $this->getAudioPath(),
];
}
}