src/Entity/Core/StudentTopic.php line 12

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity\Core;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Entity\User\User;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. #[ORM\Table('student_topic')]
  8. #[ORM\Entity(repositoryClass: \App\Repository\Core\StudentTopic::class)]
  9. class StudentTopic
  10. {
  11. #[ORM\Column(name: 'id', type: 'integer')]
  12. #[ORM\Id]
  13. #[ORM\GeneratedValue(strategy: 'AUTO')]
  14. private int $id;
  15. #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
  16. #[ORM\ManyToOne(targetEntity: User::class)]
  17. private UserInterface $user;
  18. #[ORM\Column(name: 'topic_cnt', type: 'integer')]
  19. private int $topicCnt;
  20. public function __construct(User $user, int $topicCnt)
  21. {
  22. $this->user = $user;
  23. $this->topicCnt = $topicCnt;
  24. }
  25. public function getId()
  26. {
  27. return $this->id;
  28. }
  29. public function setUser(UserInterface $user)
  30. {
  31. $this->user = $user;
  32. }
  33. public function getUser()
  34. {
  35. return $this->user;
  36. }
  37. /**
  38. * @return mixed
  39. */
  40. public function getTopicCnt()
  41. {
  42. return $this->topicCnt;
  43. }
  44. /**
  45. * @param mixed $topicCnt
  46. */
  47. public function setTopicCnt($topicCnt): void
  48. {
  49. $this->topicCnt = $topicCnt;
  50. }
  51. public function increaseTopicCnt(): void
  52. {
  53. $this->topicCnt = $this->topicCnt + 1;
  54. }
  55. public function resetTopicCnt(): void
  56. {
  57. $this->topicCnt = 1;
  58. }
  59. }