InvoiceTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. ];
  32. }
  33. public function getPrimaryKeyValue(): ?int
  34. {
  35. return $this->getId();
  36. }
  37. public function getId(): ?int
  38. {
  39. return $this->id;
  40. }
  41. public function getNumber(): ?string
  42. {
  43. return $this->number;
  44. }
  45. public function setNumber(?string $number): InvoiceTest
  46. {
  47. $this->number = $number;
  48. return $this;
  49. }
  50. public function getCode(): ?string
  51. {
  52. return $this->code;
  53. }
  54. public function setCode(?string $code): InvoiceTest
  55. {
  56. $this->code = $code;
  57. return $this;
  58. }
  59. }