CirilCivil.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Billing;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Core\File;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ApiResource(operations: [])]
  9. #[ORM\Entity]
  10. class CirilCivil
  11. {
  12. #[ORM\Id]
  13. #[ORM\Column]
  14. #[ORM\GeneratedValue]
  15. private int $id;
  16. #[ORM\OneToMany(mappedBy: 'cirilCivil', targetEntity: Bill::class, cascade: ['persist'], orphanRemoval: true)]
  17. protected Collection $bills;
  18. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
  19. protected File $file;
  20. public function getId(): int
  21. {
  22. return $this->id;
  23. }
  24. public function setId(int $id): self
  25. {
  26. $this->id = $id;
  27. return $this;
  28. }
  29. public function getBills(): Collection
  30. {
  31. return $this->bills;
  32. }
  33. public function addBill(Bill $bill): self
  34. {
  35. if (!$this->bills->contains($bill)) {
  36. $this->bills[] = $bill;
  37. $bill->setCirilCivil($this);
  38. }
  39. return $this;
  40. }
  41. public function removeBill(Bill $bill): self
  42. {
  43. $this->bills->removeElement($bill);
  44. return $this;
  45. }
  46. public function getFile(): File
  47. {
  48. return $this->file;
  49. }
  50. public function setFile(File $file): self
  51. {
  52. $this->file = $file;
  53. return $this;
  54. }
  55. }