ResidenceArea.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. declare (strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\Post;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use ApiPlatform\Metadata\Delete;
  7. use ApiPlatform\Metadata\Put;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\ApiResource;
  10. use App\Attribute\BillingSettingDefaultValue;
  11. use App\Entity\Product\IntangibleDiscountDetail;
  12. use App\Repository\Billing\ResidenceAreaRepository;
  13. //use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. use Doctrine\Common\Collections\Collection;
  17. /**
  18. * Zone de résidence d'un Access, telle que définie par l'Organization
  19. *
  20. * Security :
  21. *
  22. * @see \App\Doctrine\Billing\CurrentResidenceAreaExtension
  23. */
  24. #[ApiResource(operations: [])] // @see App\Doctrine\Billing\CurrentResidenceAreaExtension
  25. //#[Auditable]
  26. #[BillingSettingDefaultValue(fieldName: "billingSetting")]
  27. #[ORM\Entity(repositoryClass: ResidenceAreaRepository::class)]
  28. class ResidenceArea
  29. {
  30. #[ORM\Id]
  31. #[ORM\Column]
  32. #[ORM\GeneratedValue]
  33. private ?int $id = null;
  34. #[ORM\ManyToOne(targetEntity: BillingSetting::class, inversedBy: 'residenceAreas')]
  35. #[ORM\JoinColumn(nullable: false)]
  36. private BillingSetting $billingSetting;
  37. #[ORM\OneToMany(mappedBy: 'residenceArea', targetEntity: AccessBilling::class)]
  38. private Collection $accessBilling;
  39. #[ORM\OneToMany(mappedBy: 'residenceArea', targetEntity: IntangibleDiscountDetail::class)]
  40. private Collection $intangibleDiscountDetails;
  41. #[ORM\Column(length: 255)]
  42. private string $label;
  43. public function __construct()
  44. {
  45. $this->accessBilling = new ArrayCollection();
  46. $this->intangibleDiscountDetails = new ArrayCollection();
  47. }
  48. public function getId(): ?int
  49. {
  50. return $this->id;
  51. }
  52. public function getLabel(): string
  53. {
  54. return $this->label;
  55. }
  56. public function setLabel(string $label): self
  57. {
  58. $this->label = $label;
  59. return $this;
  60. }
  61. public function getBillingSetting(): ?BillingSetting
  62. {
  63. return $this->billingSetting;
  64. }
  65. public function setBillingSetting(?BillingSetting $billingSetting): self
  66. {
  67. $this->billingSetting = $billingSetting;
  68. return $this;
  69. }
  70. /**
  71. * @return Collection<int, AccessBilling>
  72. */
  73. public function getAccessBilling(): Collection
  74. {
  75. return $this->accessBilling;
  76. }
  77. public function addAccessBilling(AccessBilling $accessBilling): self
  78. {
  79. if (!$this->accessBilling->contains($accessBilling)) {
  80. $this->accessBilling[] = $accessBilling;
  81. $accessBilling->setResidenceArea($this);
  82. }
  83. return $this;
  84. }
  85. public function removeAccessBilling(AccessBilling $accessBilling): self
  86. {
  87. if ($this->accessBilling->removeElement($accessBilling)) {
  88. // set the owning side to null (unless already changed)
  89. if ($accessBilling->getResidenceArea() === $this) {
  90. $accessBilling->setResidenceArea(null);
  91. }
  92. }
  93. return $this;
  94. }
  95. /**
  96. * @return Collection<int, IntangibleDiscountDetail>
  97. */
  98. public function getIntangibleDiscountDetails(): Collection
  99. {
  100. return $this->intangibleDiscountDetails;
  101. }
  102. public function addIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
  103. {
  104. if (!$this->intangibleDiscountDetails->contains($intangibleDiscountDetail)) {
  105. $this->intangibleDiscountDetails[] = $intangibleDiscountDetail;
  106. $intangibleDiscountDetail->setResidenceArea($this);
  107. }
  108. return $this;
  109. }
  110. public function removeIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
  111. {
  112. if ($this->intangibleDiscountDetails->removeElement($intangibleDiscountDetail)) {
  113. // set the owning side to null (unless already changed)
  114. if ($intangibleDiscountDetail->getResidenceArea() === $this) {
  115. $intangibleDiscountDetail->setResidenceArea(null);
  116. }
  117. }
  118. return $this;
  119. }
  120. }