PlaceRepair.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Place;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Access\Access;
  6. use App\Entity\Core\AbstractRepair;
  7. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use App\Entity\Core\Tagg;
  9. use App\Entity\Person\CommissionMember;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. /**
  14. * @todo : A la suite de la migration, il faut supprimer le nom de la table pour avoir une table PlaceRepair, et supprimer l'attribut discr.
  15. * @todo : migration table tag_repair
  16. *
  17. * Réparation effectuée sur un lieu (Place)
  18. */
  19. // #[Auditable]
  20. #[ApiResource(operations: [])]
  21. #[ORM\Entity]
  22. class PlaceRepair extends AbstractRepair
  23. {
  24. #[ORM\ManyToOne(inversedBy: 'placeRepairProviders')]
  25. #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
  26. protected ?Access $provider = null;
  27. #[ORM\ManyToOne(inversedBy: 'repairs')]
  28. protected ?Place $place = null;
  29. /** @var Collection<int, Tagg> */
  30. #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'placeRepairs', cascade: ['persist'])]
  31. #[ORM\JoinTable(name: 'tag_repair')]
  32. #[ORM\JoinColumn(name: 'repair_id', referencedColumnName: 'id')]
  33. #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
  34. protected Collection $tags;
  35. public function __construct()
  36. {
  37. $this->tags = new ArrayCollection();
  38. }
  39. public function getProvider(): ?Access
  40. {
  41. return $this->provider;
  42. }
  43. public function setProvider(?Access $provider): self
  44. {
  45. $this->provider = $provider;
  46. return $this;
  47. }
  48. public function getPlace(): ?Place
  49. {
  50. return $this->place;
  51. }
  52. public function setPlace(?Place $place): self
  53. {
  54. $this->place = $place;
  55. return $this;
  56. }
  57. public function getTags(): Collection
  58. {
  59. return $this->tags;
  60. }
  61. public function addTag(Tagg $tag): self
  62. {
  63. if (!$this->tags->contains($tag)) {
  64. $this->tags[] = $tag;
  65. }
  66. return $this;
  67. }
  68. public function removeTag(Tagg $tag): self
  69. {
  70. $this->tags->removeElement($tag);
  71. return $this;
  72. }
  73. }