TagTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Test\PhpDevCommunity\PaperORM\Entity;
  3. use PhpDevCommunity\PaperORM\Entity\EntityInterface;
  4. use PhpDevCommunity\PaperORM\Mapping\Column\StringColumn;
  5. use PhpDevCommunity\PaperORM\Mapping\Column\DateTimeColumn;
  6. use PhpDevCommunity\PaperORM\Mapping\Column\JoinColumn;
  7. use PhpDevCommunity\PaperORM\Mapping\Column\PrimaryKeyColumn;
  8. use Test\PhpDevCommunity\PaperORM\Repository\PostTestRepository;
  9. use Test\PhpDevCommunity\PaperORM\Repository\TagTestRepository;
  10. class TagTest implements EntityInterface
  11. {
  12. private ?int $id = null;
  13. private ?string $name = null;
  14. private ?PostTest $post = null;
  15. static public function getTableName(): string
  16. {
  17. return 'tag';
  18. }
  19. static public function getRepositoryName(): string
  20. {
  21. return TagTestRepository::class;
  22. }
  23. static public function columnsMapping(): array
  24. {
  25. return [
  26. new PrimaryKeyColumn('id'),
  27. new StringColumn('name'),
  28. new JoinColumn('post', 'post_id', 'id', PostTest::class),
  29. ];
  30. }
  31. public function getPrimaryKeyValue() : ?int
  32. {
  33. return $this->getId();
  34. }
  35. public function getId(): ?int
  36. {
  37. return $this->id;
  38. }
  39. public function getName(): ?string
  40. {
  41. return $this->name;
  42. }
  43. public function setName(?string $name): TagTest
  44. {
  45. $this->name = $name;
  46. return $this;
  47. }
  48. public function getPost(): ?PostTest
  49. {
  50. return $this->post;
  51. }
  52. public function setPost(?PostTest $post): TagTest
  53. {
  54. $this->post = $post;
  55. return $this;
  56. }
  57. }