<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity
* @ORM\Table(name="ambito")
*/
class Ambito extends BaseEntity
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\Column(type="string", nullable=true, name="id_externo")
*/
private $idExterno;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $codigo;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $nombre;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2024-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
private $createdAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2024-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
private $deletedAt;
public function getId(): ?int
{
return $this->id;
}
public function setId($id): self
{
$this->id = $id;
return $this;
}
public function getIdExterno(): ?string
{
return $this->idExterno;
}
public function setIdExterno(?string $idExterno): self
{
$this->idExterno = $idExterno;
return $this;
}
public function getCodigo(): ?string
{
return $this->codigo;
}
public function setCodigo(?string $codigo): self
{
$this->codigo = $codigo;
return $this;
}
public function getNombre(): ?array
{
return $this->nombre;
}
public function setNombre(?array $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function __toString(): string
{
if (empty($this->nombre)) {
return $this->codigo ?? '';
}
return $this->nombre[$_SERVER['LOCALE'] ?? 'es'] ?? $this->nombre['ca'] ?? reset($this->nombre) ?? '';
}
}