<?php
namespace App\Entity;
use App\Repository\WardTypeRepository;
use Doctrine\Common\Collections\{ ArrayCollection, Collection };
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: WardTypeRepository::class), ORM\Table(name: 'ward_types')]
class WardType implements \Stringable
{
#[ORM\Id, ORM\GeneratedValue, ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 50), Assert\NotBlank]
#[Assert\Length(
min: 2,
max: 20,
minMessage: 'Ward type name must be at least {{ limit }} characters long',
maxMessage: 'Ward type name cannot be longer than {{ limit }} characters'
)]
#[Assert\Regex(
pattern: '/\d/',
match: false,
message: 'Ward type name cannot contain a number'
)]
private $name;
#[ORM\Column(name: 'category', type: 'string', nullable: false, columnDefinition: "enum('General','Child care','Woman care','ICU','Specialized','Surgery','OT')")]
#[Assert\NotBlank]
private $category;
#[ORM\OneToMany(targetEntity: IphsBedStrength::class, mappedBy: 'wardType', orphanRemoval: true)]
private $iphsBedStrengths;
public function __construct()
{
$this->iphsBedStrengths = 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 getCategory(): ?string
{
return $this->category;
}
public function setCategory(string $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Collection|IphsBedStrength[]
*/
public function getIphsBedStrengths(): Collection
{
return $this->iphsBedStrengths;
}
public function addIphsBedStrength(IphsBedStrength $iphsBedStrength): self
{
if (!$this->iphsBedStrengths->contains($iphsBedStrength)) {
$this->iphsBedStrengths[] = $iphsBedStrength;
$iphsBedStrength->setWardType($this);
}
return $this;
}
public function removeIphsBedStrength(IphsBedStrength $iphsBedStrength): self
{
if ($this->iphsBedStrengths->removeElement($iphsBedStrength)) {
if ($iphsBedStrength->getWardType() === $this) {
$iphsBedStrength->setWardType(null);
}
}
return $this;
}
public function __toString(): string
{
return (string) $this->getName();
}
}