EducationCategory.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Education;
  4. use ApiPlatform\Metadata\ApiResource;
  5. use App\Entity\Billing\ResidenceArea;
  6. use App\Entity\Organization\Organization;
  7. // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\Common\Collections\Collection;
  10. use Doctrine\ORM\Mapping as ORM;
  11. /**
  12. * Catégorie de l'enseignement Education
  13. */
  14. #[ApiResource(operations: [])]
  15. // #[Auditable]
  16. #[ORM\Entity]
  17. class EducationCategory
  18. {
  19. #[ORM\Id]
  20. #[ORM\Column]
  21. #[ORM\GeneratedValue]
  22. private ?int $id = null;
  23. #[ORM\ManyToOne(inversedBy: 'educationCategories')]
  24. #[ORM\JoinColumn(nullable: false)]
  25. private Organization $organization;
  26. /** @var Collection<int, Education> */
  27. #[ORM\OneToMany(targetEntity: Education::class, mappedBy: 'educationCategory', orphanRemoval: true)]
  28. private Collection $educations;
  29. public function __construct()
  30. {
  31. $this->educations = new ArrayCollection();
  32. }
  33. public function getId(): ?int
  34. {
  35. return $this->id;
  36. }
  37. public function getOrganization(): ?Organization
  38. {
  39. return $this->organization;
  40. }
  41. public function setOrganization(?Organization $organization): self
  42. {
  43. $this->organization = $organization;
  44. return $this;
  45. }
  46. /**
  47. * @return Collection<int, Education>
  48. */
  49. public function getEducations(): Collection
  50. {
  51. return $this->educations;
  52. }
  53. public function addEducation(Education $education): self
  54. {
  55. if (!$this->educations->contains($education)) {
  56. $this->educations[] = $education;
  57. $education->setEducationCategory($this);
  58. }
  59. return $this;
  60. }
  61. public function removeEducation(Education $education): self
  62. {
  63. if ($this->educations->removeElement($education)) {
  64. // set the owning side to null (unless already changed)
  65. if ($education->getEducationCategory() === $this) {
  66. $education->setEducationCategory(null);
  67. }
  68. }
  69. return $this;
  70. }
  71. }