src/Entity/Category.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
  8. */
  9. class Category
  10. {
  11. /**
  12. * @ORM\Id()
  13. * @ORM\GeneratedValue()
  14. * @ORM\Column(type="integer")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", length=50)
  19. */
  20. private $name;
  21. /**
  22. * @ORM\OneToMany(targetEntity="App\Entity\Subject", mappedBy="category")
  23. */
  24. private $subjects;
  25. /**
  26. * @ORM\ManyToMany(targetEntity="App\Entity\Teacher", mappedBy="categories")
  27. */
  28. private $teachers;
  29. /**
  30. * @ORM\OneToMany(targetEntity="App\Entity\Plan", mappedBy="category")
  31. */
  32. private $plans;
  33. /**
  34. * @ORM\OneToMany(targetEntity="App\Entity\SubscriptionOrder", mappedBy="category")
  35. */
  36. private $subscriptionOrders;
  37. /**
  38. * @ORM\Column(type="string", length=50)
  39. */
  40. private $nameEn;
  41. /**
  42. * @ORM\OneToMany(targetEntity="App\Entity\Ticket", mappedBy="category")
  43. */
  44. private $tickets;
  45. public function __construct()
  46. {
  47. $this->subjects = new ArrayCollection();
  48. $this->teachers = new ArrayCollection();
  49. $this->programs = new ArrayCollection();
  50. $this->plans = new ArrayCollection();
  51. $this->subscriptionOrders = new ArrayCollection();
  52. $this->tickets = new ArrayCollection();
  53. }
  54. public function getId(): ?int
  55. {
  56. return $this->id;
  57. }
  58. public function getName(): ?string
  59. {
  60. return $this->name;
  61. }
  62. public function setName(string $name): self
  63. {
  64. $this->name = $name;
  65. return $this;
  66. }
  67. /**
  68. * @return Collection|Subject[]
  69. */
  70. public function getSubjects(): Collection
  71. {
  72. return $this->subjects;
  73. }
  74. public function addSubject(Subject $subject): self
  75. {
  76. if (!$this->subjects->contains($subject)) {
  77. $this->subjects[] = $subject;
  78. $subject->setCategory($this);
  79. }
  80. return $this;
  81. }
  82. public function removeSubject(Subject $subject): self
  83. {
  84. if ($this->subjects->contains($subject)) {
  85. $this->subjects->removeElement($subject);
  86. // set the owning side to null (unless already changed)
  87. if ($subject->getCategory() === $this) {
  88. $subject->setCategory(null);
  89. }
  90. }
  91. return $this;
  92. }
  93. public function __toString()
  94. {
  95. return $this->getName();
  96. }
  97. /**
  98. * @return Collection|Teacher[]
  99. */
  100. public function getTeachers(): Collection
  101. {
  102. return $this->teachers;
  103. }
  104. public function addTeacher(Teacher $teacher): self
  105. {
  106. if (!$this->teachers->contains($teacher)) {
  107. $this->teachers[] = $teacher;
  108. $teacher->addCategory($this);
  109. }
  110. return $this;
  111. }
  112. public function removeTeacher(Teacher $teacher): self
  113. {
  114. if ($this->teachers->contains($teacher)) {
  115. $this->teachers->removeElement($teacher);
  116. $teacher->removeCategory($this);
  117. }
  118. return $this;
  119. }
  120. /**
  121. * @return Collection|Plan[]
  122. */
  123. public function getPlans(): Collection
  124. {
  125. return $this->plans;
  126. }
  127. public function addPlan(Plan $plan): self
  128. {
  129. if (!$this->plans->contains($plan)) {
  130. $this->plans[] = $plan;
  131. $plan->setCategory($this);
  132. }
  133. return $this;
  134. }
  135. public function removePlan(Plan $plan): self
  136. {
  137. if ($this->plans->contains($plan)) {
  138. $this->plans->removeElement($plan);
  139. // set the owning side to null (unless already changed)
  140. if ($plan->getCategory() === $this) {
  141. $plan->setCategory(null);
  142. }
  143. }
  144. return $this;
  145. }
  146. /**
  147. * @return Collection|SubscriptionOrder[]
  148. */
  149. public function getSubscriptionOrders(): Collection
  150. {
  151. return $this->subscriptionOrders;
  152. }
  153. public function addSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
  154. {
  155. if (!$this->subscriptionOrders->contains($subscriptionOrder)) {
  156. $this->subscriptionOrders[] = $subscriptionOrder;
  157. $subscriptionOrder->setCategory($this);
  158. }
  159. return $this;
  160. }
  161. public function removeSubscriptionOrder(SubscriptionOrder $subscriptionOrder): self
  162. {
  163. if ($this->subscriptionOrders->contains($subscriptionOrder)) {
  164. $this->subscriptionOrders->removeElement($subscriptionOrder);
  165. // set the owning side to null (unless already changed)
  166. if ($subscriptionOrder->getCategory() === $this) {
  167. $subscriptionOrder->setCategory(null);
  168. }
  169. }
  170. return $this;
  171. }
  172. public function getNameEn(): ?string
  173. {
  174. return $this->nameEn;
  175. }
  176. public function setNameEn(?string $nameEn): self
  177. {
  178. $this->nameEn = $nameEn;
  179. return $this;
  180. }
  181. /**
  182. * @return Collection|Ticket[]
  183. */
  184. public function getTickets(): Collection
  185. {
  186. return $this->tickets;
  187. }
  188. public function addTicket(Ticket $ticket): self
  189. {
  190. if (!$this->tickets->contains($ticket)) {
  191. $this->tickets[] = $ticket;
  192. $ticket->setCategory($this);
  193. }
  194. return $this;
  195. }
  196. public function removeTicket(Ticket $ticket): self
  197. {
  198. if ($this->tickets->contains($ticket)) {
  199. $this->tickets->removeElement($ticket);
  200. // set the owning side to null (unless already changed)
  201. if ($ticket->getCategory() === $this) {
  202. $ticket->setCategory(null);
  203. }
  204. }
  205. return $this;
  206. }
  207. }