src/Entity/Vs/VsAbo.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: 'vsabo')]
  8. class VsAbo implements \Stringable
  9. {
  10. public const int ABO_STD_OHNE_INSERAT = 2; // ID aus DB
  11. public const int ABO_STD_MIT_INSERAT = 3; // ID aus DB
  12. public const int ABO_PREM_OHNE_INSERAT = 4; // ID aus DB
  13. public const int ABO_PREM_MIT_INSERAT = 5; // ID aus DB
  14. #[ORM\Column(name: 'id', type: 'integer')]
  15. #[ORM\Id]
  16. #[ORM\GeneratedValue(strategy: 'AUTO')]
  17. private ?int $id = null;
  18. #[ORM\OneToMany(mappedBy: 'abo', targetEntity: Vs::class)]
  19. private Collection $vss;
  20. #[ORM\Column(name: 'aboname', type: 'string', length: 200, unique: false, nullable: true)]
  21. private ?string $aboname = null;
  22. #[ORM\Column(name: 'aboname_short', type: 'string', length: 8, nullable: true)]
  23. private ?string $abonameShort = null;
  24. #[ORM\Column(name: 'max_length_vs_titel', type: 'integer', nullable: true)]
  25. private ?int $maxLengthVsTitel = null;
  26. #[ORM\Column(name: 'max_length_vs_beschreibung', type: 'integer', nullable: true)]
  27. private ?int $maxLengthVsBeschreibung = null;
  28. public function __construct()
  29. {
  30. $this->vss = new ArrayCollection();
  31. }
  32. public function getId(): ?int
  33. {
  34. return $this->id;
  35. }
  36. public function getAboname(): ?string
  37. {
  38. return $this->aboname;
  39. }
  40. public function setAboname(?string $aboname): VsAbo
  41. {
  42. $this->aboname = $aboname;
  43. return $this;
  44. }
  45. public function getAbonameShort(): ?string
  46. {
  47. return $this->abonameShort;
  48. }
  49. public function setAbonameShort(?string $abonameShort): VsAbo
  50. {
  51. $this->abonameShort = $abonameShort;
  52. return $this;
  53. }
  54. public function getMaxLengthVsTitel(): ?int
  55. {
  56. return $this->maxLengthVsTitel;
  57. }
  58. public function setMaxLengthVsTitel(?int $maxLengthVsTitel): VsAbo
  59. {
  60. $this->maxLengthVsTitel = $maxLengthVsTitel;
  61. return $this;
  62. }
  63. public function getMaxLengthVsBeschreibung(): ?int
  64. {
  65. return $this->maxLengthVsBeschreibung;
  66. }
  67. public function setMaxLengthVsBeschreibung(?int $maxLengthVsBeschreibung): VsAbo
  68. {
  69. $this->maxLengthVsBeschreibung = $maxLengthVsBeschreibung;
  70. return $this;
  71. }
  72. #[\Override]
  73. public function __toString(): string
  74. {
  75. return $this->getAboname();
  76. }
  77. public function addVss(Vs $vss): static
  78. {
  79. $this->vss[] = $vss;
  80. return $this;
  81. }
  82. public function removeVss(Vs $vss): void
  83. {
  84. $this->vss->removeElement($vss);
  85. }
  86. public function getVss(): ArrayCollection|Collection
  87. {
  88. return $this->vss;
  89. }
  90. // Helpers
  91. public function isStandardOhneInserat(): bool
  92. {
  93. return $this->id === self::ABO_STD_OHNE_INSERAT;
  94. }
  95. public function isStandardMitInserat(): bool
  96. {
  97. return $this->id === self::ABO_STD_MIT_INSERAT;
  98. }
  99. public function isStandard(): bool
  100. {
  101. return $this->isStandardOhneInserat() || $this->isStandardMitInserat();
  102. }
  103. public function isPremiumOhneInserat(): bool
  104. {
  105. return $this->id === self::ABO_PREM_OHNE_INSERAT;
  106. }
  107. public function isPremiumMitInserat(): bool
  108. {
  109. return $this->id === self::ABO_PREM_MIT_INSERAT;
  110. }
  111. public function isPremium(): bool
  112. {
  113. return $this->isPremiumOhneInserat() || $this->isPremiumMitInserat();
  114. }
  115. }