<?php
namespace App\Entity;
use App\Repository\HospitalRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=HospitalRepository::class)
* @ORM\HasLifecycleCallbacks()
*/
class Hospital
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $updateAt;
/**
* @ORM\ManyToOne(targetEntity=Municipality::class, inversedBy="hospitals")
* @ORM\JoinColumn(nullable=false)
*/
private $municipality;
/**
* @ORM\OneToMany(targetEntity=Child::class, mappedBy="hospital")
*/
private $children;
/**
* @ORM\ManyToOne(targetEntity=HospitalCategory::class, inversedBy="hospitals")
*/
private $hospitalCategory;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="hospital")
*/
private $users;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $phoneNumber;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $neighborhood;
/**
* @ORM\OneToMany(targetEntity=DeathCertificate::class, mappedBy="placeOfDeath")
*/
private $deathCertificates;
public function __construct()
{
$this->enfants = new ArrayCollection();
$this->__updateDate();
$this->children = new ArrayCollection();
$this->users = new ArrayCollection();
$this->deathCertificates = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getUpdateAt(): ?\DateTimeInterface
{
return $this->updateAt;
}
public function setUpdateAt(?\DateTimeInterface $updateAt): self
{
$this->updateAt = $updateAt;
return $this;
}
public function getMunicipality(): ?Municipality
{
return $this->municipality;
}
public function setMunicipality(?Municipality $municipality): self
{
$this->municipality = $municipality;
return $this;
}
public function __toString() {
return $this->getName();
}
/**
* @ORM\PreUpdate
*/
public function __updateDate() {
$this->setUpdateAt(new \DateTime());
}
/**
* @return Collection|Child[]
*/
public function getChildren(): Collection
{
return $this->children;
}
public function addChild(Child $child): self
{
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setHospital($this);
}
return $this;
}
public function removeChild(Child $child): self
{
if ($this->children->contains($child)) {
$this->children->removeElement($child);
// set the owning side to null (unless already changed)
if ($child->getHospital() === $this) {
$child->setHospital(null);
}
}
return $this;
}
public function getHospitalCategory(): ?HospitalCategory
{
return $this->hospitalCategory;
}
public function setHospitalCategory(?HospitalCategory $hospitalCategory): self
{
$this->hospitalCategory = $hospitalCategory;
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setHospital($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getHospital() === $this) {
$user->setHospital(null);
}
}
return $this;
}
public function getPhoneNumber(): ?string
{
return $this->phoneNumber;
}
public function setPhoneNumber(?string $phoneNumber): self
{
$this->phoneNumber = $phoneNumber;
return $this;
}
public function getNeighborhood(): ?string
{
return $this->neighborhood;
}
public function setNeighborhood(?string $neighborhood): self
{
$this->neighborhood = $neighborhood;
return $this;
}
/**
* @return Collection|DeathCertificate[]
*/
public function getDeathCertificates(): Collection
{
return $this->deathCertificates;
}
public function addDeathCertificate(DeathCertificate $deathCertificate): self
{
if (!$this->deathCertificates->contains($deathCertificate)) {
$this->deathCertificates[] = $deathCertificate;
$deathCertificate->setPlaceOfDeath($this);
}
return $this;
}
public function removeDeathCertificate(DeathCertificate $deathCertificate): self
{
if ($this->deathCertificates->removeElement($deathCertificate)) {
// set the owning side to null (unless already changed)
if ($deathCertificate->getPlaceOfDeath() === $this) {
$deathCertificate->setPlaceOfDeath(null);
}
}
return $this;
}
}