src/Entity/Ambito.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Gedmo\Mapping\Annotation as Gedmo;
  5. /**
  6. * @ORM\Entity
  7. * @ORM\Table(name="ambito")
  8. */
  9. class Ambito extends BaseEntity
  10. {
  11. /**
  12. * @ORM\Id
  13. * @ORM\Column(type="integer")
  14. * @ORM\GeneratedValue(strategy="AUTO")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", nullable=true, name="id_externo")
  19. */
  20. private $idExterno;
  21. /**
  22. * @ORM\Column(type="string", length=50, nullable=true)
  23. */
  24. private $codigo;
  25. /**
  26. * @ORM\Column(type="json", nullable=true)
  27. */
  28. private $nombre;
  29. /**
  30. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2024-01-01 00:00:00"})
  31. * @Gedmo\Timestampable(on="create")
  32. */
  33. private $createdAt;
  34. /**
  35. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2024-01-01 00:00:00"})
  36. * @Gedmo\Timestampable(on="update")
  37. */
  38. private $updatedAt;
  39. /**
  40. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  41. */
  42. private $deletedAt;
  43. public function getId(): ?int
  44. {
  45. return $this->id;
  46. }
  47. public function setId($id): self
  48. {
  49. $this->id = $id;
  50. return $this;
  51. }
  52. public function getIdExterno(): ?string
  53. {
  54. return $this->idExterno;
  55. }
  56. public function setIdExterno(?string $idExterno): self
  57. {
  58. $this->idExterno = $idExterno;
  59. return $this;
  60. }
  61. public function getCodigo(): ?string
  62. {
  63. return $this->codigo;
  64. }
  65. public function setCodigo(?string $codigo): self
  66. {
  67. $this->codigo = $codigo;
  68. return $this;
  69. }
  70. public function getNombre(): ?array
  71. {
  72. return $this->nombre;
  73. }
  74. public function setNombre(?array $nombre): self
  75. {
  76. $this->nombre = $nombre;
  77. return $this;
  78. }
  79. public function getCreatedAt(): ?\DateTimeInterface
  80. {
  81. return $this->createdAt;
  82. }
  83. public function setCreatedAt(\DateTimeInterface $createdAt): self
  84. {
  85. $this->createdAt = $createdAt;
  86. return $this;
  87. }
  88. public function getUpdatedAt(): ?\DateTimeInterface
  89. {
  90. return $this->updatedAt;
  91. }
  92. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  93. {
  94. $this->updatedAt = $updatedAt;
  95. return $this;
  96. }
  97. public function getDeletedAt(): ?\DateTimeInterface
  98. {
  99. return $this->deletedAt;
  100. }
  101. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  102. {
  103. $this->deletedAt = $deletedAt;
  104. return $this;
  105. }
  106. public function __toString(): string
  107. {
  108. if (empty($this->nombre)) {
  109. return $this->codigo ?? '';
  110. }
  111. return $this->nombre[$_SERVER['LOCALE'] ?? 'es'] ?? $this->nombre['ca'] ?? reset($this->nombre) ?? '';
  112. }
  113. }