src/Entity/Vs/VsStatus.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Vs;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity]
  7. #[ORM\Table(name: 'vsstatus')]
  8. class VsStatus implements \Stringable
  9. {
  10. public const int STAT_ERFASST = 1; // ID aus DB
  11. public const int STAT_KORREKTUR = 2; // ID aus DB
  12. public const int STAT_ANZEIGEN = 3; // ID aus DB
  13. public const int STAT_STORNIERT = 4; // ID aus DB
  14. public const int STAT_NONE = 5; // ID aus DB (NICHT ZUGEWIESEN)
  15. #[ORM\Column(name: 'id', type: 'integer')]
  16. #[ORM\Id]
  17. #[ORM\GeneratedValue(strategy: 'AUTO')]
  18. private ?int $id = null;
  19. #[ORM\Column(name: 'statusname', type: 'string', length: 200, unique: false, nullable: true)]
  20. private ?string $statusname = null;
  21. #[ORM\OneToMany(mappedBy: 'status', targetEntity: Vs::class)]
  22. private Collection $vss;
  23. public function __construct()
  24. {
  25. $this->vss = new ArrayCollection();
  26. }
  27. public function getId(): ?int
  28. {
  29. return $this->id;
  30. }
  31. public function getStatusname(): ?string
  32. {
  33. return $this->statusname;
  34. }
  35. public function setStatusname(?string $statusname): VsStatus
  36. {
  37. $this->statusname = $statusname;
  38. return $this;
  39. }
  40. public function getStatusnameShort(): string
  41. {
  42. return strtoupper(substr($this->getStatusname(), 0, 1));
  43. }
  44. public function addVss(Vs $vss): static
  45. {
  46. $this->vss[] = $vss;
  47. return $this;
  48. }
  49. public function removeVss(Vs $vss): void
  50. {
  51. $this->vss->removeElement($vss);
  52. }
  53. public function getVss(): ArrayCollection|Collection
  54. {
  55. return $this->vss;
  56. }
  57. // Helpers
  58. public function isErfasst(): bool
  59. {
  60. return $this->id === self::STAT_ERFASST;
  61. }
  62. public function isAnzeigen(): bool
  63. {
  64. return $this->id === self::STAT_ANZEIGEN;
  65. }
  66. public function isKorrektur(): bool
  67. {
  68. return $this->id === self::STAT_KORREKTUR;
  69. }
  70. public function isStorniert(): bool
  71. {
  72. return $this->id === self::STAT_STORNIERT;
  73. }
  74. public function isNichtZugewiesen(): bool
  75. {
  76. return $this->id === self::STAT_NONE;
  77. }
  78. #[\Override]
  79. public function __toString(): string
  80. {
  81. return $this->getStatusname();
  82. }
  83. }