SddRegie.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use App\Entity\Core\File;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11. * TODO: documenter
  12. * // TODO: possible factoriser avec SddBank?
  13. */
  14. // #[Auditable]
  15. #[ApiResource(operations: [])]
  16. #[ORM\Entity]
  17. class SddRegie
  18. {
  19. #[ORM\Id]
  20. #[ORM\Column]
  21. #[ORM\GeneratedValue]
  22. private ?int $id = null;
  23. /** @var Collection<int, BillPayment> */
  24. #[ORM\OneToMany(mappedBy: 'sddRegime', targetEntity: BillPayment::class, cascade: [], orphanRemoval: false)]
  25. protected Collection $billPayments;
  26. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'], inversedBy: 'sddRegieFile')]
  27. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  28. protected ?File $file;
  29. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'], inversedBy: 'sddRegieBordereau')]
  30. #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
  31. protected ?File $bordereau;
  32. public function __construct()
  33. {
  34. $this->billPayments = new ArrayCollection();
  35. }
  36. public function getId(): ?int
  37. {
  38. return $this->id;
  39. }
  40. public function getBillPayments(): Collection
  41. {
  42. return $this->billPayments;
  43. }
  44. public function addBillPayment(BillPayment $billPayment): self
  45. {
  46. if (!$this->billPayments->contains($billPayment)) {
  47. $this->billPayments[] = $billPayment;
  48. $billPayment->setSddRegie($this);
  49. }
  50. return $this;
  51. }
  52. public function removeBillPayment(BillPayment $billPayment): self
  53. {
  54. if ($this->billPayments->removeElement($billPayment)) {
  55. // $billPayment->setSddBank(null); // TODO: actuellement, pas nullable: conserver?
  56. }
  57. return $this;
  58. }
  59. public function getFile(): ?File
  60. {
  61. return $this->file;
  62. }
  63. public function setFile(?File $file): self
  64. {
  65. $this->file = $file;
  66. return $this;
  67. }
  68. public function getBordereau(): ?File
  69. {
  70. return $this->bordereau;
  71. }
  72. public function setBordereau(?File $bordereau): self
  73. {
  74. $this->bordereau = $bordereau;
  75. return $this;
  76. }
  77. }