BillSchedule.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\AccessWish\AccessWish;
  6. use App\Entity\Organization\Organization;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ApiResource(operations: [])]
  10. #[ORM\Entity]
  11. class BillSchedule
  12. {
  13. #[ORM\Id]
  14. #[ORM\Column]
  15. #[ORM\GeneratedValue]
  16. private int $id;
  17. #[ORM\ManyToOne(targetEntity: Organization::class, cascade: [], inversedBy: 'billSchedules')]
  18. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: false, onDelete: 'SET NULL')]
  19. protected Organization $organization;
  20. #[ORM\OneToMany(mappedBy: 'billSchedule', targetEntity: BillScheduleDate::class, cascade: ['persist'], orphanRemoval: true)]
  21. protected Collection $scheduleDates;
  22. #[ORM\OneToMany(mappedBy: 'billSchedule', targetEntity: AccessBilling::class, cascade: [], orphanRemoval: false)] // TODO: à revoir
  23. protected Collection $accessBilling;
  24. #[ORM\OneToMany(mappedBy: 'billSchedule', targetEntity: AccessWish::class, cascade: [], orphanRemoval: false)] // TODO: à revoir
  25. protected Collection $accessWishes;
  26. public function getId(): int
  27. {
  28. return $this->id;
  29. }
  30. public function setId(int $id): self
  31. {
  32. $this->id = $id;
  33. return $this;
  34. }
  35. public function getOrganization(): Organization
  36. {
  37. return $this->organization;
  38. }
  39. public function setOrganization(Organization $organization): self
  40. {
  41. $this->organization = $organization;
  42. return $this;
  43. }
  44. public function getScheduleDates(): Collection
  45. {
  46. return $this->scheduleDates;
  47. }
  48. public function addScheduleDate(BillScheduleDate $scheduleDate): self
  49. {
  50. if (!$this->scheduleDates->contains($scheduleDate)) {
  51. $this->scheduleDates[] = $scheduleDate;
  52. $scheduleDate->setBillSchedule($this);
  53. }
  54. return $this;
  55. }
  56. public function removeScheduleDate(BillScheduleDate $scheduleDate): self
  57. {
  58. if ($this->scheduleDates->removeElement($scheduleDate)) {
  59. $scheduleDate->setBillSchedule(null);
  60. }
  61. return $this;
  62. }
  63. public function getAccessBilling(): Collection
  64. {
  65. return $this->accessBilling;
  66. }
  67. public function addAccessBilling(AccessBilling $accessBilling): self
  68. {
  69. if (!$this->accessBilling->contains($accessBilling)) {
  70. $this->accessBilling[] = $accessBilling;
  71. $accessBilling->setBillSchedule($this);
  72. }
  73. return $this;
  74. }
  75. public function removeAccessBilling(AccessBilling $accessBilling): self
  76. {
  77. if ($this->accessBilling->removeElement($accessBilling)) {
  78. // $accessBilling->setBillSchedule(null); // TODO: actuellement, pas nullable: conserver?
  79. }
  80. return $this;
  81. }
  82. public function getAccessWishes(): Collection
  83. {
  84. return $this->accessWishes;
  85. }
  86. public function addAccessWish(AccessWish $accessWish): self
  87. {
  88. if (!$this->accessWishes->contains($accessWish)) {
  89. $this->accessWishes[] = $accessWish;
  90. $accessWish->setBillSchedule($this);
  91. }
  92. return $this;
  93. }
  94. public function removeAccessWish(AccessWish $accessWish): self
  95. {
  96. if ($this->accessWishes->removeElement($accessWish)) {
  97. // $accessWish->setBillSchedule(null); // TODO: actuellement, pas nullable: conserver?
  98. }
  99. return $this;
  100. }
  101. }