src/Entity/Channel/Payment/LicensesOrder.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Channel\Payment;
  3. use App\Entity\Channel\Channel;
  4. use App\Entity\Common\LicenseEmbeddable;
  5. use App\Repository\Channel\Payment\LicensesOrderRepository;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use DrosalysWeb\ObjectExtensions\Blame\Model\BlameInterface;
  8. use DrosalysWeb\ObjectExtensions\Blame\Model\BlameTrait;
  9. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampInterface;
  10. use DrosalysWeb\ObjectExtensions\Timestamp\Model\TimestampTrait;
  11. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. #[
  14. ORM\Entity(repositoryClass: LicensesOrderRepository::class),
  15. ORM\Table(name: 'channel_licenses_order'),
  16. // UniqueEntity(fields: ['orderNumber'], message: 'licenses_order.unique_entity.message')
  17. ]
  18. class LicensesOrder implements BlameInterface, TimestampInterface
  19. {
  20. use BlameTrait;
  21. use TimestampTrait;
  22. #[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
  23. private ?int $id = null;
  24. #[ORM\ManyToOne(targetEntity: Channel::class)]
  25. #[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
  26. private ?Channel $channel = null;
  27. #[ORM\Embedded(class: LicenseEmbeddable::class)]
  28. #[Assert\Valid]
  29. private ?LicenseEmbeddable $license = null;
  30. #[ORM\Column(type: 'string', length: 11, nullable: true)]
  31. #[Assert\Regex('/^FA\d{8}$/')]
  32. private ?string $orderNumber = null;
  33. #[ORM\Column(type: 'integer', nullable: true)]
  34. private ?int $status = null;
  35. #[ORM\Column(type: 'integer', nullable: false)]
  36. private ?int $tva = null;
  37. #[ORM\Column(type: 'boolean', nullable: false)]
  38. private bool $archived = false;
  39. public function getId(): ?int
  40. {
  41. return $this->id;
  42. }
  43. public function getChannel(): ?Channel
  44. {
  45. return $this->channel;
  46. }
  47. public function setChannel(?Channel $channel): LicensesOrder
  48. {
  49. $this->channel = $channel;
  50. return $this;
  51. }
  52. public function getLicense(): ?LicenseEmbeddable
  53. {
  54. return $this->license;
  55. }
  56. public function setLicense(?LicenseEmbeddable $license): static
  57. {
  58. $this->license = $license;
  59. return $this;
  60. }
  61. public function getOrderNumber(): ?string
  62. {
  63. return $this->orderNumber;
  64. }
  65. public function setOrderNumber(?string $orderNumber): LicensesOrder
  66. {
  67. $this->orderNumber = $orderNumber;
  68. return $this;
  69. }
  70. public function getTva(): ?int
  71. {
  72. return $this->tva;
  73. }
  74. public function setTva(?int $tva): void
  75. {
  76. $this->tva = $tva;
  77. }
  78. public function getTvaDisplayed(): float
  79. {
  80. return $this->tva !== null ? $this->tva / 100 : 0;
  81. }
  82. public function getStatus(): ?int
  83. {
  84. return $this->status;
  85. }
  86. public function setStatus(?int $status): LicensesOrder
  87. {
  88. $this->status = $status;
  89. return $this;
  90. }
  91. public function isArchived(): bool
  92. {
  93. return $this->archived;
  94. }
  95. public function setArchived(bool $archived): LicensesOrder
  96. {
  97. $this->archived = $archived;
  98. return $this;
  99. }
  100. public function toggleIsArchived(): LicensesOrder
  101. {
  102. $this->archived = !$this->archived;
  103. return $this;
  104. }
  105. }