src/Entity/ChildPreferenceTime.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ChildPreferenceTimeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\Serializer\Annotation\Groups;
  6. /**
  7. * @ORM\Entity(repositoryClass=ChildPreferenceTimeRepository::class)
  8. */
  9. class ChildPreferenceTime
  10. {
  11. /**
  12. * @ORM\Id
  13. * @ORM\GeneratedValue
  14. * @ORM\Column(type="integer")
  15. * @Groups({"ChildPreferenceEdit"})
  16. */
  17. private $id;
  18. /**
  19. * @ORM\ManyToOne(targetEntity=ChildPreference::class, inversedBy="childPreferenceTimes")
  20. */
  21. private $childPreference;
  22. /**
  23. * @ORM\Column(type="time", nullable=true)
  24. * @Groups({"ChildPreferenceList","ChildPreferenceEdit"})
  25. */
  26. private $startTime;
  27. /**
  28. * @ORM\Column(type="time", nullable=true)
  29. * @Groups({"ChildPreferenceList","ChildPreferenceEdit"})
  30. */
  31. private $endTime;
  32. /**
  33. * @ORM\Column(type="integer", nullable=true)
  34. * @Groups({"ChildPreferenceList","ChildPreferenceEdit"})
  35. */
  36. private $weekday;
  37. /**
  38. * @ORM\Column(type="datetime", nullable=true)
  39. */
  40. private $createdAt;
  41. public function __construct()
  42. {
  43. $this->createdAt = new \Datetime();
  44. }
  45. public function getId(): ?int
  46. {
  47. return $this->id;
  48. }
  49. public function getChildPreference(): ?ChildPreference
  50. {
  51. return $this->childPreference;
  52. }
  53. public function setChildPreference(?ChildPreference $childPreference): self
  54. {
  55. $this->childPreference = $childPreference;
  56. return $this;
  57. }
  58. public function getStartTime(): ?\DateTimeInterface
  59. {
  60. return $this->startTime;
  61. }
  62. public function setStartTime(?\DateTimeInterface $startTime): self
  63. {
  64. $this->startTime = $startTime;
  65. return $this;
  66. }
  67. public function getEndTime(): ?\DateTimeInterface
  68. {
  69. return $this->endTime;
  70. }
  71. public function setEndTime(?\DateTimeInterface $endTime): self
  72. {
  73. $this->endTime = $endTime;
  74. return $this;
  75. }
  76. public function getWeekday(): ?int
  77. {
  78. return $this->weekday;
  79. }
  80. public function getWeekdayString()
  81. {
  82. $day = $this->weekday;
  83. if ($day == 1) {
  84. return 'Pirmadienis';
  85. }
  86. if ($day == 2) {
  87. return 'Antradienis';
  88. }
  89. if ($day == 3) {
  90. return 'Trečiadienis';
  91. }
  92. if ($day == 4) {
  93. return 'Ketvirtadienis';
  94. }
  95. if ($day == 5) {
  96. return 'Penktadienis';
  97. }
  98. if ($day == 6) {
  99. return 'Šeštadienis';
  100. }
  101. if ($day == 7) {
  102. return 'Sekmadienis';
  103. } else {
  104. return "";
  105. }
  106. }
  107. public function setWeekday(?int $weekday): self
  108. {
  109. $this->weekday = $weekday;
  110. return $this;
  111. }
  112. public function getCreatedAt(): ?\DateTimeInterface
  113. {
  114. return $this->createdAt;
  115. }
  116. public function setCreatedAt(?\DateTimeInterface $createdAt): self
  117. {
  118. $this->createdAt = $createdAt;
  119. return $this;
  120. }
  121. }