src/Entity/WardType.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\WardTypeRepository;
  4. use Doctrine\Common\Collections\{ ArrayCollectionCollection };
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. #[ORM\Entity(repositoryClassWardTypeRepository::class), ORM\Table(name'ward_types')]
  8. class WardType implements \Stringable
  9. {
  10.     #[ORM\IdORM\GeneratedValueORM\Column(type'integer')]
  11.     private $id;
  12.     #[ORM\Column(type'string'length50), Assert\NotBlank]
  13.     #[Assert\Length(
  14.         min2,
  15.         max20,
  16.         minMessage'Ward type name must be at least {{ limit }} characters long',
  17.         maxMessage'Ward type name cannot be longer than {{ limit }} characters'
  18.     )]
  19.     #[Assert\Regex(
  20.         pattern'/\d/',
  21.         match: false,
  22.         message'Ward type name cannot contain a number'
  23.     )]
  24.     private $name;
  25.     #[ORM\Column(name'category'type'string'nullablefalsecolumnDefinition"enum('General','Child care','Woman care','ICU','Specialized','Surgery','OT')")]
  26.     #[Assert\NotBlank]
  27.     private $category;
  28.     #[ORM\OneToMany(targetEntityIphsBedStrength::class, mappedBy'wardType'orphanRemovaltrue)]
  29.     private $iphsBedStrengths;
  30.     public function __construct()
  31.     {
  32.         $this->iphsBedStrengths = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): self
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function getCategory(): ?string
  48.     {
  49.         return $this->category;
  50.     }
  51.     public function setCategory(string $category): self
  52.     {
  53.         $this->category $category;
  54.         return $this;
  55.     }
  56.     /**
  57.      * @return Collection|IphsBedStrength[]
  58.      */
  59.     public function getIphsBedStrengths(): Collection
  60.     {
  61.         return $this->iphsBedStrengths;
  62.     }
  63.     public function addIphsBedStrength(IphsBedStrength $iphsBedStrength): self
  64.     {
  65.         if (!$this->iphsBedStrengths->contains($iphsBedStrength)) {
  66.             $this->iphsBedStrengths[] = $iphsBedStrength;
  67.             $iphsBedStrength->setWardType($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeIphsBedStrength(IphsBedStrength $iphsBedStrength): self
  72.     {
  73.         if ($this->iphsBedStrengths->removeElement($iphsBedStrength)) {
  74.             if ($iphsBedStrength->getWardType() === $this) {
  75.                 $iphsBedStrength->setWardType(null);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80.     public function __toString(): string
  81.     {
  82.         return (string) $this->getName();
  83.     }
  84. }