src/Entity/Archivo.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Asistencia\Entity\Anuncio;
  4. use App\Repository\ArchivoRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9. * @ORM\Entity(repositoryClass=ArchivoRepository::class)
  10. */
  11. class Archivo
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\GeneratedValue
  16. * @ORM\Column(type="integer")
  17. */
  18. private $id;
  19. /**
  20. * @ORM\Column(type="blob")
  21. */
  22. private $archivo;
  23. /**
  24. * @ORM\Column(type="text", nullable=true)
  25. */
  26. private $nombre;
  27. /**
  28. * @ORM\Column(type="string", length=255, nullable=true)
  29. */
  30. private $extencion;
  31. /**
  32. * @ORM\Column(type="string", length=255, nullable=true)
  33. */
  34. private $mime_type;
  35. /**
  36. * @ORM\Column(type="integer", nullable=true)
  37. */
  38. private $size;
  39. /**
  40. * @ORM\Column(type="text", nullable=true)
  41. */
  42. private $origen;
  43. /**
  44. * @ORM\OneToMany(targetEntity=ArchivoCurso::class, mappedBy="archivo")
  45. */
  46. private $archivoCursos;
  47. /**
  48. * @ORM\OneToMany(targetEntity=TareaArchivo::class, mappedBy="archivo")
  49. */
  50. private $tareaArchivos;
  51. /**
  52. * @ORM\OneToMany(targetEntity=TareaEstudianteArchivo::class, mappedBy="archivo")
  53. */
  54. private $tareaEstudianteArchivos;
  55. /**
  56. * @ORM\Column(type="text", nullable=true)
  57. */
  58. private $base64;
  59. public function __construct()
  60. {
  61. $this->archivoCursos = new ArrayCollection();
  62. $this->tareaArchivos = new ArrayCollection();
  63. $this->tareaEstudianteArchivos = new ArrayCollection();
  64. }
  65. public function getId(): ?int
  66. {
  67. return $this->id;
  68. }
  69. public function getArchivo()
  70. {
  71. return $this->archivo;
  72. }
  73. public function setArchivo($archivo): self
  74. {
  75. $this->archivo = $archivo;
  76. return $this;
  77. }
  78. public function getNombre(): ?string
  79. {
  80. return $this->nombre;
  81. }
  82. public function setNombre(?string $nombre): self
  83. {
  84. $this->nombre = $nombre;
  85. return $this;
  86. }
  87. public function getExtencion(): ?string
  88. {
  89. return $this->extencion;
  90. }
  91. public function setExtencion(?string $extencion): self
  92. {
  93. $this->extencion = $extencion;
  94. return $this;
  95. }
  96. public function getMimeType(): ?string
  97. {
  98. return $this->mime_type;
  99. }
  100. public function setMimeType(?string $mime_type): self
  101. {
  102. $this->mime_type = $mime_type;
  103. return $this;
  104. }
  105. public function getSize(): ?int
  106. {
  107. return $this->size;
  108. }
  109. public function setSize(?int $size): self
  110. {
  111. $this->size = $size;
  112. return $this;
  113. }
  114. public function getOrigen(): ?string
  115. {
  116. return $this->origen;
  117. }
  118. public function setOrigen(?string $origen): self
  119. {
  120. $this->origen = $origen;
  121. return $this;
  122. }
  123. /**
  124. * @return Collection<int, ArchivoCurso>
  125. */
  126. public function getArchivoCursos(): Collection
  127. {
  128. return $this->archivoCursos;
  129. }
  130. public function addArchivoCurso(ArchivoCurso $archivoCurso): self
  131. {
  132. if (!$this->archivoCursos->contains($archivoCurso)) {
  133. $this->archivoCursos[] = $archivoCurso;
  134. $archivoCurso->setArchivo($this);
  135. }
  136. return $this;
  137. }
  138. public function removeArchivoCurso(ArchivoCurso $archivoCurso): self
  139. {
  140. if ($this->archivoCursos->removeElement($archivoCurso)) {
  141. // set the owning side to null (unless already changed)
  142. if ($archivoCurso->getArchivo() === $this) {
  143. $archivoCurso->setArchivo(null);
  144. }
  145. }
  146. return $this;
  147. }
  148. /**
  149. * @return Collection<int, TareaArchivo>
  150. */
  151. public function getTareaArchivos(): Collection
  152. {
  153. return $this->tareaArchivos;
  154. }
  155. public function addTareaArchivo(TareaArchivo $tareaArchivo): self
  156. {
  157. if (!$this->tareaArchivos->contains($tareaArchivo)) {
  158. $this->tareaArchivos[] = $tareaArchivo;
  159. $tareaArchivo->setArchivo($this);
  160. }
  161. return $this;
  162. }
  163. public function removeTareaArchivo(TareaArchivo $tareaArchivo): self
  164. {
  165. if ($this->tareaArchivos->removeElement($tareaArchivo)) {
  166. // set the owning side to null (unless already changed)
  167. if ($tareaArchivo->getArchivo() === $this) {
  168. $tareaArchivo->setArchivo(null);
  169. }
  170. }
  171. return $this;
  172. }
  173. public function getBase(): string{
  174. return base64_encode(stream_get_contents($this->getArchivo()));
  175. }
  176. /**
  177. * @return Collection<int, TareaEstudianteArchivo>
  178. */
  179. public function getTareaEstudianteArchivos(): Collection
  180. {
  181. return $this->tareaEstudianteArchivos;
  182. }
  183. public function addTareaEstudianteArchivo(TareaEstudianteArchivo $tareaEstudianteArchivo): self
  184. {
  185. if (!$this->tareaEstudianteArchivos->contains($tareaEstudianteArchivo)) {
  186. $this->tareaEstudianteArchivos[] = $tareaEstudianteArchivo;
  187. $tareaEstudianteArchivo->setArchivo($this);
  188. }
  189. return $this;
  190. }
  191. public function removeTareaEstudianteArchivo(TareaEstudianteArchivo $tareaEstudianteArchivo): self
  192. {
  193. if ($this->tareaEstudianteArchivos->removeElement($tareaEstudianteArchivo)) {
  194. // set the owning side to null (unless already changed)
  195. if ($tareaEstudianteArchivo->getArchivo() === $this) {
  196. $tareaEstudianteArchivo->setArchivo(null);
  197. }
  198. }
  199. return $this;
  200. }
  201. public function getBase64(): ?string
  202. {
  203. return $this->base64;
  204. }
  205. public function setBase64(?string $base64): self
  206. {
  207. $this->base64 = $base64;
  208. return $this;
  209. }
  210. }