src/Entity/Tablet.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TabletRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9. * @ORM\Entity(repositoryClass=TabletRepository::class)
  10. */
  11. class Tablet
  12. {
  13. const STATUS_FREE = [
  14. 'value' => "FREE",
  15. 'text' => 'Laisva',
  16. 'color' => '#54c44f',
  17. 'description' => ''
  18. ];
  19. const STATUS_NOT_WORKING = [
  20. 'value' => "NOT_WORKING",
  21. 'text' => 'Neveikianti',
  22. 'color' => '#54c44f',
  23. 'description' => ''
  24. ];
  25. const STATUS_WAITING_SIGNATURE = [
  26. 'value' => "WAITING_SIGNATURE",
  27. 'text' => 'Laukiama parašo',
  28. 'color' => '#54c44f',
  29. 'description' => ''
  30. ];
  31. const STATUS_RETURN_WAITING_SIGNATURE = [
  32. 'value' => "WAITING_RETURN_SIGNATURE",
  33. 'text' => 'Laukiama grąžinimo parašo',
  34. 'color' => '#54c44f',
  35. 'description' => ''
  36. ];
  37. const STATUS_GIVEN = [
  38. 'value' => "GIVEN_SIGNED",
  39. 'text' => 'Išduota ir pasirašyta',
  40. 'color' => '#54c44f',
  41. 'description' => ''
  42. ];
  43. const STATUS_RETURNED = [
  44. 'value' => "RETURNED",
  45. 'text' => 'Grąžinta',
  46. 'color' => '#54c44f',
  47. 'description' => ''
  48. ];
  49. const STATUS_MUST_RETURN = [
  50. 'value' => "MUST_RETURN",
  51. 'text' => 'Turi grąžinti planšetę',
  52. 'color' => '#54c44f',
  53. 'description' => ''
  54. ];
  55. const TABLET_STATUSES = [self::STATUS_FREE, self::STATUS_WAITING_SIGNATURE, self::STATUS_RETURN_WAITING_SIGNATURE, self::STATUS_RETURNED, self::STATUS_GIVEN, self::STATUS_NOT_WORKING, self::STATUS_MUST_RETURN];
  56. const TABLET_STATUSES_REVERSED = [
  57. self::STATUS_FREE['value'] => self::STATUS_FREE['text'],
  58. self::STATUS_NOT_WORKING['value'] => self::STATUS_NOT_WORKING['text'],
  59. self::STATUS_WAITING_SIGNATURE['value'] => self::STATUS_WAITING_SIGNATURE['text'],
  60. self::STATUS_RETURN_WAITING_SIGNATURE['value'] => self::STATUS_RETURN_WAITING_SIGNATURE['text'],
  61. self::STATUS_RETURNED['value'] => self::STATUS_RETURNED['text'],
  62. self::STATUS_GIVEN['value'] => self::STATUS_GIVEN['text'],
  63. self::STATUS_MUST_RETURN['value'] => self::STATUS_MUST_RETURN['text'],
  64. ];
  65. /**
  66. * @ORM\Id
  67. * @ORM\GeneratedValue
  68. * @ORM\Column(type="integer")
  69. * @Groups({"TabletList"})
  70. */
  71. private $id;
  72. /**
  73. * @ORM\Column(type="string", length=255, nullable=true)
  74. * @Groups({"TabletList"})
  75. */
  76. private $number;
  77. /**
  78. * @ORM\Column(type="string", length=255, nullable=true)
  79. * @Groups({"TabletList"})
  80. */
  81. private $status;
  82. /**
  83. * @ORM\ManyToOne(targetEntity=Teacher::class, inversedBy="tablets")
  84. * @Groups({"TabletList"})
  85. */
  86. private $teacher;
  87. /**
  88. * @ORM\OneToMany(targetEntity=TeacherTablet::class, mappedBy="tablet")
  89. * @Groups({"TabletList"})
  90. */
  91. private $teacherTablets;
  92. /**
  93. * @ORM\Column(type="text", nullable=true)
  94. * @Groups({"TabletList"})
  95. */
  96. private $comment;
  97. public function __construct()
  98. {
  99. $this->teacherTablets = new ArrayCollection();
  100. }
  101. public function getId(): ?int
  102. {
  103. return $this->id;
  104. }
  105. public function getNumber(): ?string
  106. {
  107. return $this->number;
  108. }
  109. public function setNumber(?string $number): self
  110. {
  111. $this->number = $number;
  112. return $this;
  113. }
  114. public function getStatus(): ?string
  115. {
  116. return $this->status;
  117. }
  118. public function setStatus(?string $status): self
  119. {
  120. $this->status = $status;
  121. return $this;
  122. }
  123. public function getTeacher(): ?Teacher
  124. {
  125. return $this->teacher;
  126. }
  127. public function setTeacher(?Teacher $teacher): self
  128. {
  129. $this->teacher = $teacher;
  130. return $this;
  131. }
  132. /**
  133. * @return Collection<int, TeacherTablet>
  134. */
  135. public function getTeacherTablets(): Collection
  136. {
  137. return $this->teacherTablets;
  138. }
  139. public function addTeacherTablet(TeacherTablet $teacherTablet): self
  140. {
  141. if (!$this->teacherTablets->contains($teacherTablet)) {
  142. $this->teacherTablets[] = $teacherTablet;
  143. $teacherTablet->setTablet($this);
  144. }
  145. return $this;
  146. }
  147. public function removeTeacherTablet(TeacherTablet $teacherTablet): self
  148. {
  149. if ($this->teacherTablets->removeElement($teacherTablet)) {
  150. // set the owning side to null (unless already changed)
  151. if ($teacherTablet->getTablet() === $this) {
  152. $teacherTablet->setTablet(null);
  153. }
  154. }
  155. return $this;
  156. }
  157. public function __toString(): string
  158. {
  159. return "{$this->id} - {$this->number}";
  160. }
  161. public function getComment(): ?string
  162. {
  163. return $this->comment;
  164. }
  165. public function setComment(?string $comment): self
  166. {
  167. $this->comment = $comment;
  168. return $this;
  169. }
  170. }