AccessIntangible.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Access\Access;
  6. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  7. use App\Repository\Billing\AccessIntangibleRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12. * Enregistrement d'un produit à facturer par un Access.
  13. */
  14. #[ApiResource(operations: [])]
  15. // #[Auditable]
  16. #[ORM\Entity(repositoryClass: AccessIntangibleRepository::class)]
  17. #[ORM\Table(name: 'BillingIntangible')]
  18. class AccessIntangible extends AbstractBillingIntangible
  19. {
  20. #[ORM\ManyToOne(inversedBy: 'accessIntangibles')]
  21. private ?Access $access = null;
  22. /** @var Collection<int, BillingIntangibleExcludeDate> */
  23. #[ORM\OneToMany(targetEntity: BillingIntangibleExcludeDate::class, mappedBy: 'accessIntangible', cascade: ['persist'], orphanRemoval: true)]
  24. private Collection $billingIntangibleExcludeDates;
  25. public function __construct()
  26. {
  27. $this->billingIntangibleExcludeDates = new ArrayCollection();
  28. parent::__construct();
  29. }
  30. public function setAccess(?Access $access): self
  31. {
  32. $this->access = $access;
  33. return $this;
  34. }
  35. public function getAccess(): ?Access
  36. {
  37. return $this->access;
  38. }
  39. /**
  40. * @return Collection<int, BillingIntangibleExcludeDate>
  41. */
  42. public function getBillingIntangibleExcludeDates(): Collection
  43. {
  44. return $this->billingIntangibleExcludeDates;
  45. }
  46. public function addBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  47. {
  48. if (!$this->billingIntangibleExcludeDates->contains($billingIntangibleExcludeDate)) {
  49. $this->billingIntangibleExcludeDates[] = $billingIntangibleExcludeDate;
  50. $billingIntangibleExcludeDate->setAccessIntangible($this);
  51. }
  52. return $this;
  53. }
  54. public function removeBillingIntangibleExcludeDate(BillingIntangibleExcludeDate $billingIntangibleExcludeDate): self
  55. {
  56. if ($this->billingIntangibleExcludeDates->removeElement($billingIntangibleExcludeDate)) {
  57. // set the owning side to null (unless already changed)
  58. if ($billingIntangibleExcludeDate->getAccessIntangible() === $this) {
  59. $billingIntangibleExcludeDate->setAccessIntangible(null);
  60. }
  61. }
  62. return $this;
  63. }
  64. }