vendor/roothirsch/shop-bundle/Entity/Discount.php line 32

Open in your IDE?
  1. <?php
  2. namespace Roothirsch\ShopBundle\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use Roothirsch\ShopBundle\Repository\DiscountRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Serializer\Annotation\Groups;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. use Gedmo\Translatable\Translatable;
  9. /**
  10. * @ORM\Entity(repositoryClass=DiscountRepository::class)
  11. * @ORM\Table(name="shop_discount")
  12. * @ApiResource(
  13. * attributes={
  14. * "order"={"startDate": "DESC"}
  15. * },
  16. * normalizationContext={"groups"={"discount_read"}},
  17. * denormalizationContext={"groups"={"discount_write"}},
  18. * collectionOperations={
  19. * "get"={"path"="/discounts"},
  20. * "post"
  21. * },
  22. * itemOperations={
  23. * "get",
  24. * "put",
  25. * "delete"
  26. * }
  27. * )
  28. */
  29. class Discount implements Translatable
  30. {
  31. /**
  32. * @ORM\Id
  33. * @ORM\GeneratedValue
  34. * @ORM\Column(type="integer")
  35. * @Groups({"discount_read"})
  36. */
  37. private $id;
  38. /**
  39. * @Gedmo\Translatable
  40. * @ORM\Column(type="string", length=255)
  41. * @Groups({"discount_read", "discount_write"})
  42. */
  43. private $name;
  44. /**
  45. * @ORM\Column(type="float")
  46. * @Groups({"discount_read", "discount_write"})
  47. */
  48. private $value;
  49. /**
  50. * Helper text for the admin interface to indicate that discount values should be negative
  51. */
  52. /**
  53. * @ORM\Column(type="date")
  54. * @Groups({"discount_read", "discount_write"})
  55. */
  56. private $startDate;
  57. /**
  58. * @ORM\Column(type="date")
  59. * @Groups({"discount_read", "discount_write"})
  60. */
  61. private $endDate;
  62. /**
  63. * @ORM\Column(type="boolean")
  64. * @Groups({"discount_read", "discount_write"})
  65. */
  66. private $active = true;
  67. /**
  68. * @ORM\Column(type="string", length=255, options={"default"="percentageAfterDiscounts"})
  69. * @Groups({"discount_read", "discount_write"})
  70. */
  71. private $type = 'percentageAfterDiscounts';
  72. /**
  73. * @ORM\Column(type="string", length=255, nullable=true)
  74. * @Groups({"discount_read", "discount_write"})
  75. */
  76. private $category;
  77. public function getId(): ?int
  78. {
  79. return $this->id;
  80. }
  81. public function getName(): ?string
  82. {
  83. return $this->name;
  84. }
  85. public function setName(string $name): self
  86. {
  87. $this->name = $name;
  88. return $this;
  89. }
  90. public function getValue(): ?float
  91. {
  92. return $this->value;
  93. }
  94. public function setValue(float $value): self
  95. {
  96. $this->value = $value;
  97. return $this;
  98. }
  99. public function getStartDate(): ?\DateTimeInterface
  100. {
  101. return $this->startDate;
  102. }
  103. public function setStartDate(\DateTimeInterface $startDate): self
  104. {
  105. $this->startDate = $startDate;
  106. return $this;
  107. }
  108. public function getEndDate(): ?\DateTimeInterface
  109. {
  110. return $this->endDate;
  111. }
  112. public function setEndDate(\DateTimeInterface $endDate): self
  113. {
  114. $this->endDate = $endDate;
  115. return $this;
  116. }
  117. public function isActive(): ?bool
  118. {
  119. return $this->active;
  120. }
  121. public function setActive(bool $active): self
  122. {
  123. $this->active = $active;
  124. return $this;
  125. }
  126. public function getType(): ?string
  127. {
  128. return $this->type;
  129. }
  130. public function setType(string $type): self
  131. {
  132. $this->type = $type;
  133. return $this;
  134. }
  135. public function getCategory(): ?string
  136. {
  137. return $this->category;
  138. }
  139. public function setCategory(?string $category): self
  140. {
  141. $this->category = $category;
  142. return $this;
  143. }
  144. }