Odyssee.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 Odyssee
  11. {
  12. #[ORM\Id]
  13. #[ORM\Column]
  14. #[ORM\GeneratedValue]
  15. private int $id;
  16. #[ORM\OneToMany(mappedBy: 'odyssee', 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->setOdyssee($this);
  38. }
  39. return $this;
  40. }
  41. public function removeBill(Bill $bill): self
  42. {
  43. if ($this->bills->removeElement($bill)) {
  44. // $bill->setOdyssee(null); // TODO: actuellement, pas nullable: conserver?
  45. }
  46. return $this;
  47. }
  48. public function getFile(): File
  49. {
  50. return $this->file;
  51. }
  52. public function setFile(File $file): self
  53. {
  54. $this->file = $file;
  55. return $this;
  56. }
  57. }