SddBank.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. */
  13. // #[Auditable]
  14. #[ApiResource(operations: [])]
  15. #[ORM\Entity]
  16. class SddBank
  17. {
  18. #[ORM\Id]
  19. #[ORM\Column]
  20. #[ORM\GeneratedValue]
  21. private ?int $id = null;
  22. /** @var Collection<int, BillPayment> */
  23. #[ORM\OneToMany(targetEntity: BillPayment::class, mappedBy: 'sddBank', cascade: [], orphanRemoval: false)]
  24. protected Collection $billPayments;
  25. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
  26. protected ?File $file;
  27. public function __construct()
  28. {
  29. $this->billPayments = new ArrayCollection();
  30. }
  31. public function getId(): ?int
  32. {
  33. return $this->id;
  34. }
  35. public function getBillPayments(): Collection
  36. {
  37. return $this->billPayments;
  38. }
  39. public function addBillPayment(BillPayment $billPayment): self
  40. {
  41. if (!$this->billPayments->contains($billPayment)) {
  42. $this->billPayments[] = $billPayment;
  43. $billPayment->setSddBank($this);
  44. }
  45. return $this;
  46. }
  47. public function removeBillPayment(BillPayment $billPayment): self
  48. {
  49. if ($this->billPayments->removeElement($billPayment)) {
  50. // $billPayment->setSddBank(null); // TODO: actuellement, pas nullable: conserver?
  51. }
  52. return $this;
  53. }
  54. public function getFile(): ?File
  55. {
  56. return $this->file;
  57. }
  58. public function setFile(?File $file): self
  59. {
  60. $this->file = $file;
  61. return $this;
  62. }
  63. }