src/Core/Entity/Color.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Core\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="App\Core\Repository\ColorRepository")
  8. */
  9. class Color
  10. {
  11. /**
  12. * @ORM\Id()
  13. * @ORM\GeneratedValue()
  14. * @ORM\Column(type="integer")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", length=15)
  19. */
  20. private $nombre;
  21. /**
  22. * @ORM\Column(type="string", length=7)
  23. */
  24. private $codigo;
  25. /**
  26. * @ORM\OneToMany(targetEntity="App\Core\Entity\Curso", mappedBy="color")
  27. */
  28. private $cursos;
  29. public function __construct()
  30. {
  31. $this->cursos = new ArrayCollection();
  32. }
  33. public function getId(): ?int
  34. {
  35. return $this->id;
  36. }
  37. public function getNombre(): ?string
  38. {
  39. return $this->nombre;
  40. }
  41. public function setNombre(string $nombre): self
  42. {
  43. $this->nombre = $nombre;
  44. return $this;
  45. }
  46. public function getCodigo(): ?string
  47. {
  48. return $this->codigo;
  49. }
  50. public function setCodigo(string $codigo): self
  51. {
  52. $this->codigo = $codigo;
  53. return $this;
  54. }
  55. /**
  56. * @return Collection|Curso[]
  57. */
  58. public function getCursos(): Collection
  59. {
  60. return $this->cursos;
  61. }
  62. public function addCurso(Curso $curso): self
  63. {
  64. if (!$this->cursos->contains($curso)) {
  65. $this->cursos[] = $curso;
  66. $curso->setColor($this);
  67. }
  68. return $this;
  69. }
  70. public function removeCurso(Curso $curso): self
  71. {
  72. if ($this->cursos->contains($curso)) {
  73. $this->cursos->removeElement($curso);
  74. // set the owning side to null (unless already changed)
  75. if ($curso->getColor() === $this) {
  76. $curso->setColor(null);
  77. }
  78. }
  79. return $this;
  80. }
  81. }