src/Entity/ConventionCollective.php line 19

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\Repository\ConventionCollectiveRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * ConventionCollective.
  10. *
  11. * @ORM\Table(name="ConventionCollective")
  12. *
  13. * @ORM\Entity(repositoryClass=ConventionCollectiveRepository::class)
  14. */
  15. class ConventionCollective
  16. {
  17. /**
  18. * @ORM\Id
  19. *
  20. * @ORM\GeneratedValue
  21. *
  22. * @ORM\Column(type="integer")
  23. */
  24. private ?int $id = null;
  25. /**
  26. * @ORM\Column(name="nom", type="string", length=255)
  27. */
  28. private string $nom;
  29. /**
  30. * @ORM\OneToMany(targetEntity="Structure", mappedBy="conventionCollective")
  31. */
  32. private Collection $structures;
  33. public function __construct()
  34. {
  35. $this->structures = new ArrayCollection();
  36. }
  37. public function __toString(): string
  38. {
  39. return $this->nom;
  40. }
  41. public function getId(): ?int
  42. {
  43. return $this->id;
  44. }
  45. public function getNom(): string
  46. {
  47. return $this->nom;
  48. }
  49. public function setNom(string $nom): static
  50. {
  51. $this->nom = $nom;
  52. return $this;
  53. }
  54. /**
  55. * @return Collection<int, Structure>
  56. */
  57. public function getStructures(): Collection
  58. {
  59. return $this->structures;
  60. }
  61. public function addStructure(Structure $structure): static
  62. {
  63. if (!$this->structures->contains($structure)) {
  64. $this->structures->add($structure);
  65. $structure->setConventionCollective($this);
  66. }
  67. return $this;
  68. }
  69. public function removeStructure(Structure $structure): static
  70. {
  71. if ($this->structures->removeElement($structure)) {
  72. if ($structure->getConventionCollective() === $this) {
  73. $structure->setConventionCollective(null);
  74. }
  75. }
  76. return $this;
  77. }
  78. }