<?php
namespace App\Entity\Core;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Table(name: 'appendix')]
#[ORM\Entity]
class Appendix implements JsonSerializable
{
/**
* @var int
*/
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
/**
* @var string
*/
#[ORM\Column(name: 'file_name', type: 'string', length: 255, unique: true)]
private $fileName;
/**
* @var ArrayCollection
*/
#[ORM\ManyToMany(targetEntity: Mathproblem::class, mappedBy: 'appendices')]
private $problems;
public function __construct()
{
$this->problems = new ArrayCollection();
}
public function getId(): int
{
return $this->id;
}
public function setFileName(string $fileName)
{
$this->fileName = $fileName;
}
public function getFileName(): string
{
return $this->fileName;
}
public function getProblems(): Collection
{
return $this->problems;
}
public function setProblems(ArrayCollection $problems): void
{
$this->problems = $problems;
}
public function jsonSerialize(): array
{
return [
'id' => $this->id,
'fileName' => '/appendices/' . $this->fileName
];
}
}