Jvs.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 Jvs
  17. {
  18. #[ORM\Id]
  19. #[ORM\Column]
  20. #[ORM\GeneratedValue]
  21. private ?int $id = null;
  22. /** @var Collection<int, Bill> */
  23. #[ORM\OneToMany(targetEntity: Bill::class, mappedBy: 'jvs', cascade: ['persist'], orphanRemoval: true)]
  24. private Collection $bills;
  25. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
  26. protected ?File $file;
  27. public function __construct()
  28. {
  29. $this->bills = new ArrayCollection();
  30. }
  31. public function getId(): ?int
  32. {
  33. return $this->id;
  34. }
  35. /**
  36. * @return Collection<int, Bill>
  37. */
  38. public function getBills(): Collection
  39. {
  40. return $this->bills;
  41. }
  42. public function addBill(Bill $bill): self
  43. {
  44. if (!$this->bills->contains($bill)) {
  45. $this->bills[] = $bill;
  46. $bill->setJvs($this);
  47. }
  48. return $this;
  49. }
  50. public function removeBill(Bill $bill): self
  51. {
  52. if ($this->bills->removeElement($bill)) {
  53. // set the owning side to null (unless already changed)
  54. if ($bill->getJvs() === $this) {
  55. $bill->setJvs(null);
  56. }
  57. }
  58. return $this;
  59. }
  60. public function getFile(): ?File
  61. {
  62. return $this->file;
  63. }
  64. public function setFile(?File $file): self
  65. {
  66. $this->file = $file;
  67. return $this;
  68. }
  69. }