InvoiceTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace Test\PhpDevCommunity\PaperORM\Entity;
  3. use PhpDevCommunity\PaperORM\Entity\EntityInterface;
  4. use PhpDevCommunity\PaperORM\Mapping\Column\AutoIncrementColumn;
  5. use PhpDevCommunity\PaperORM\Mapping\Column\JoinColumn;
  6. use PhpDevCommunity\PaperORM\Mapping\Column\PrimaryKeyColumn;
  7. use PhpDevCommunity\PaperORM\Mapping\Entity;
  8. #[Entity(table: 'invoice', repository: null)]
  9. class InvoiceTest implements EntityInterface
  10. {
  11. #[PrimaryKeyColumn]
  12. private ?int $id = null;
  13. #[AutoIncrementColumn(pad: 8, prefix: 'INV-{YYYY}-', key: 'invoice.number')]
  14. private ?string $number = null;
  15. #[AutoIncrementColumn(pad: 8, key: 'invoice.code')]
  16. private ?string $code = null;
  17. static public function getTableName(): string
  18. {
  19. return 'invoice';
  20. }
  21. static public function getRepositoryName(): ?string
  22. {
  23. return null;
  24. }
  25. static public function columnsMapping(): array
  26. {
  27. return [
  28. (new PrimaryKeyColumn())->bindProperty('id'),
  29. (new AutoIncrementColumn(null, 'invoice.number', 6, 'INV-{YYYY}-'))->bindProperty('number'),
  30. (new AutoIncrementColumn(null, 'invoice.code', 8, null))->bindProperty('code'),
  31. (new JoinColumn('post_id', PostTest::class))->bindProperty('post'),
  32. ];
  33. }
  34. public function getPrimaryKeyValue(): ?int
  35. {
  36. return $this->getId();
  37. }
  38. public function getId(): ?int
  39. {
  40. return $this->id;
  41. }
  42. public function getNumber(): ?string
  43. {
  44. return $this->number;
  45. }
  46. public function setNumber(?string $number): InvoiceTest
  47. {
  48. $this->number = $number;
  49. return $this;
  50. }
  51. public function getCode(): ?string
  52. {
  53. return $this->code;
  54. }
  55. public function setCode(?string $code): InvoiceTest
  56. {
  57. $this->code = $code;
  58. return $this;
  59. }
  60. }