Odyssee.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /**
  9. * TODO: documenter
  10. */
  11. #[ApiResource(operations: [])]
  12. #[ORM\Entity]
  13. class Odyssee
  14. {
  15. #[ORM\Id]
  16. #[ORM\Column]
  17. #[ORM\GeneratedValue]
  18. private int $id;
  19. /** @var Collection<int, Bill> */
  20. #[ORM\OneToMany(targetEntity: Bill::class, mappedBy: 'odyssee', cascade: ['persist'], orphanRemoval: true)]
  21. protected Collection $bills;
  22. #[ORM\OneToOne(targetEntity: File::class, cascade: ['persist'])]
  23. protected ?File $file;
  24. public function getId(): int
  25. {
  26. return $this->id;
  27. }
  28. public function setId(int $id): self
  29. {
  30. $this->id = $id;
  31. return $this;
  32. }
  33. public function getBills(): Collection
  34. {
  35. return $this->bills;
  36. }
  37. public function addBill(Bill $bill): self
  38. {
  39. if (!$this->bills->contains($bill)) {
  40. $this->bills[] = $bill;
  41. $bill->setOdyssee($this);
  42. }
  43. return $this;
  44. }
  45. public function removeBill(Bill $bill): self
  46. {
  47. if ($this->bills->removeElement($bill)) {
  48. // $bill->setOdyssee(null); // TODO: actuellement, pas nullable: conserver?
  49. }
  50. return $this;
  51. }
  52. public function getFile(): ?File
  53. {
  54. return $this->file;
  55. }
  56. public function setFile(?File $file): self
  57. {
  58. $this->file = $file;
  59. return $this;
  60. }
  61. }