FamilyQuotient.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use App\Entity\Product\IntangibleDiscountDetail;
  6. use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * Classe ... qui ...
  12. */
  13. #[Auditable]
  14. #[ORM\Entity]
  15. #[ApiResource(
  16. collectionOperations:[],
  17. itemOperations: [
  18. "get" => ["security" => "is_granted('ROLE_ADMIN') and object.getBillingSetting().getOrganization().getId() == user.getOrganization().getId()"]
  19. ]
  20. )]
  21. class FamilyQuotient
  22. {
  23. #[ORM\Id]
  24. #[ORM\Column]
  25. #[ORM\GeneratedValue]
  26. private ?int $id = null;
  27. #[ORM\ManyToOne(inversedBy: 'familyQuotients')]
  28. #[ORM\JoinColumn(nullable: false)]
  29. private BillingSetting $billingSetting;
  30. #[ORM\OneToMany(mappedBy: 'familyQuotient', targetEntity: AccessBilling::class)]
  31. private Collection $accessBilling;
  32. #[ORM\OneToMany(mappedBy: 'familyQuotient', targetEntity: IntangibleDiscountDetail::class)]
  33. private Collection $intangibleDiscountDetails;
  34. public function __construct()
  35. {
  36. $this->accessBilling = new ArrayCollection();
  37. $this->intangibleDiscountDetails = new ArrayCollection();
  38. }
  39. public function getId(): ?int
  40. {
  41. return $this->id;
  42. }
  43. public function getBillingSetting(): ?BillingSetting
  44. {
  45. return $this->billingSetting;
  46. }
  47. public function setBillingSetting(?BillingSetting $billingSetting): self
  48. {
  49. $this->billingSetting = $billingSetting;
  50. return $this;
  51. }
  52. /**
  53. * @return Collection<int, AccessBilling>
  54. */
  55. public function getAccessBilling(): Collection
  56. {
  57. return $this->accessBilling;
  58. }
  59. public function addAccessBilling(AccessBilling $accessBilling): self
  60. {
  61. if (!$this->accessBilling->contains($accessBilling)) {
  62. $this->accessBilling[] = $accessBilling;
  63. $accessBilling->setFamilyQuotient($this);
  64. }
  65. return $this;
  66. }
  67. public function removeAccessBilling(AccessBilling $accessBilling): self
  68. {
  69. if ($this->accessBilling->removeElement($accessBilling)) {
  70. // set the owning side to null (unless already changed)
  71. if ($accessBilling->getFamilyQuotient() === $this) {
  72. $accessBilling->setFamilyQuotient(null);
  73. }
  74. }
  75. return $this;
  76. }
  77. /**
  78. * @return Collection<int, IntangibleDiscountDetail>
  79. */
  80. public function getIntangibleDiscountDetails(): Collection
  81. {
  82. return $this->intangibleDiscountDetails;
  83. }
  84. public function addIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
  85. {
  86. if (!$this->intangibleDiscountDetails->contains($intangibleDiscountDetail)) {
  87. $this->intangibleDiscountDetails[] = $intangibleDiscountDetail;
  88. $intangibleDiscountDetail->setFamilyQuotient($this);
  89. }
  90. return $this;
  91. }
  92. public function removeIntangibleDiscountDetail(IntangibleDiscountDetail $intangibleDiscountDetail): self
  93. {
  94. if ($this->intangibleDiscountDetails->removeElement($intangibleDiscountDetail)) {
  95. // set the owning side to null (unless already changed)
  96. if ($intangibleDiscountDetail->getFamilyQuotient() === $this) {
  97. $intangibleDiscountDetail->setFamilyQuotient(null);
  98. }
  99. }
  100. return $this;
  101. }
  102. }