<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProvinciaRepository")
* @ORM\Table(name="provincia", schema="perseo")
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
*/
class Provincia
{
/**
* @ORM\Id
* @ORM\Column(type="bigint")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100, nullable=false)
* @Gedmo\Translatable
*/
protected $nombre;
/**
* @ORM\Column(type="datetime", nullable=true, name="deleted_at")
*/
protected $deletedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="update")
*/
protected $updatedAt;
/**
* @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
* @Gedmo\Timestampable(on="create")
*/
protected $createdAt;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Ciudad", mappedBy="provincia")
*/
protected $ciudades;
/**
* @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="provincia")
*/
protected $user;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Cliente", mappedBy="provincia")
*/
protected $clientes;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionFacturacionProvincia")
*/
protected $direccionFacturacionProvinciaVentas;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Venta", mappedBy="direccionEnvioProvincia")
*/
protected $direccionEnvioProvinciaVentas;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\CCAA", inversedBy="provincias")
* @ORM\JoinColumn(name="ccaa_id", referencedColumnName="id", nullable=false)
*/
protected $ccaa;
public function __construct()
{
$this->ciudades = new ArrayCollection();
$this->user = new ArrayCollection();
$this->direccionFacturacionProvinciaVentas = new ArrayCollection();
$this->direccionEnvioProvinciaVentas = new ArrayCollection();
$this->clientes = new ArrayCollection();
}
public function __toString(): string
{
return $this->getNombre()??'---';
}
public function getId(): ?string
{
return $this->id;
}
public function getNombre(): ?string
{
return $this->nombre;
}
public function setNombre(string $nombre): self
{
$this->nombre = $nombre;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* @return Collection|Ciudad[]
*/
public function getCiudades(): Collection
{
return $this->ciudades;
}
public function addCiudade(Ciudad $ciudade): self
{
if (!$this->ciudades->contains($ciudade)) {
$this->ciudades[] = $ciudade;
$ciudade->setProvincia($this);
}
return $this;
}
public function removeCiudade(Ciudad $ciudade): self
{
if ($this->ciudades->removeElement($ciudade)) {
// set the owning side to null (unless already changed)
if ($ciudade->getProvincia() === $this) {
$ciudade->setProvincia(null);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getUser(): Collection
{
return $this->user;
}
public function addUser(User $user): self
{
if (!$this->user->contains($user)) {
$this->user[] = $user;
$user->setProvincia($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->user->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getProvincia() === $this) {
$user->setProvincia(null);
}
}
return $this;
}
/**
* @return Collection|Venta[]
*/
public function getDireccionFacturacionProvinciaVentas(): Collection
{
return $this->direccionFacturacionProvinciaVentas;
}
public function addDireccionFacturacionProvinciaVenta(Venta $direccionFacturacionProvinciaVenta): self
{
if (!$this->direccionFacturacionProvinciaVentas->contains($direccionFacturacionProvinciaVenta)) {
$this->direccionFacturacionProvinciaVentas[] = $direccionFacturacionProvinciaVenta;
$direccionFacturacionProvinciaVenta->setDireccionFacturacionProvincia($this);
}
return $this;
}
public function removeDireccionFacturacionProvinciaVenta(Venta $direccionFacturacionProvinciaVenta): self
{
if ($this->direccionFacturacionProvinciaVentas->removeElement($direccionFacturacionProvinciaVenta)) {
// set the owning side to null (unless already changed)
if ($direccionFacturacionProvinciaVenta->getDireccionFacturacionProvincia() === $this) {
$direccionFacturacionProvinciaVenta->setDireccionFacturacionProvincia(null);
}
}
return $this;
}
/**
* @return Collection|Venta[]
*/
public function getDireccionEnvioProvinciaVentas(): Collection
{
return $this->direccionEnvioProvinciaVentas;
}
public function addDireccionEnvioProvinciaVenta(Venta $direccionEnvioProvinciaVenta): self
{
if (!$this->direccionEnvioProvinciaVentas->contains($direccionEnvioProvinciaVenta)) {
$this->direccionEnvioProvinciaVentas[] = $direccionEnvioProvinciaVenta;
$direccionEnvioProvinciaVenta->setDireccionEnvioProvincia($this);
}
return $this;
}
public function removeDireccionEnvioProvinciaVenta(Venta $direccionEnvioProvinciaVenta): self
{
if ($this->direccionEnvioProvinciaVentas->removeElement($direccionEnvioProvinciaVenta)) {
// set the owning side to null (unless already changed)
if ($direccionEnvioProvinciaVenta->getDireccionEnvioProvincia() === $this) {
$direccionEnvioProvinciaVenta->setDireccionEnvioProvincia(null);
}
}
return $this;
}
public function getCcaa(): ?CCAA
{
return $this->ccaa;
}
public function setCcaa(?CCAA $ccaa): self
{
$this->ccaa = $ccaa;
return $this;
}
/**
* @return Collection|Cliente[]
*/
public function getClientes(): Collection
{
return $this->clientes;
}
public function addCliente(Cliente $cliente): self
{
if (!$this->clientes->contains($cliente)) {
$this->clientes[] = $cliente;
$cliente->setProvincia($this);
}
return $this;
}
public function removeCliente(Cliente $cliente): self
{
if ($this->clientes->removeElement($cliente)) {
// set the owning side to null (unless already changed)
if ($cliente->getProvincia() === $this) {
$cliente->setProvincia(null);
}
}
return $this;
}
}