src/Entity/Core/Appendix.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Core;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use JsonSerializable;
  7. #[ORM\Table(name: 'appendix')]
  8. #[ORM\Entity]
  9. class Appendix implements JsonSerializable
  10. {
  11. /**
  12. * @var int
  13. */
  14. #[ORM\Column(name: 'id', type: 'integer')]
  15. #[ORM\Id]
  16. #[ORM\GeneratedValue(strategy: 'AUTO')]
  17. private $id;
  18. /**
  19. * @var string
  20. */
  21. #[ORM\Column(name: 'file_name', type: 'string', length: 255, unique: true)]
  22. private $fileName;
  23. /**
  24. * @var ArrayCollection
  25. */
  26. #[ORM\ManyToMany(targetEntity: Mathproblem::class, mappedBy: 'appendices')]
  27. private $problems;
  28. public function __construct()
  29. {
  30. $this->problems = new ArrayCollection();
  31. }
  32. public function getId(): int
  33. {
  34. return $this->id;
  35. }
  36. public function setFileName(string $fileName)
  37. {
  38. $this->fileName = $fileName;
  39. }
  40. public function getFileName(): string
  41. {
  42. return $this->fileName;
  43. }
  44. public function getProblems(): Collection
  45. {
  46. return $this->problems;
  47. }
  48. public function setProblems(ArrayCollection $problems): void
  49. {
  50. $this->problems = $problems;
  51. }
  52. public function jsonSerialize(): array
  53. {
  54. return [
  55. 'id' => $this->id,
  56. 'fileName' => '/appendices/' . $this->fileName
  57. ];
  58. }
  59. }