src/Entity/Core/Peer/PeerStudent.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Core\Peer;
  3. use App\Entity\User\User;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use JsonSerializable;
  6. #[ORM\Table('peer_student')]
  7. #[ORM\Entity]
  8. class PeerStudent implements JsonSerializable
  9. {
  10. #[ORM\Column(name: 'id', type: 'integer')]
  11. #[ORM\Id]
  12. #[ORM\GeneratedValue(strategy: 'AUTO')]
  13. private int $id;
  14. #[ORM\Column(name: 'is_team_leader', type: 'boolean', options: ['default' => false])]
  15. private bool $isTeamLeader;
  16. #[ORM\JoinColumn(name: 'PeerUnit', referencedColumnName: 'id', onDelete: 'CASCADE')]
  17. #[ORM\ManyToOne(targetEntity: PeerUnit::class, inversedBy: 'peerStudents')]
  18. private PeerUnit $peerUnit;
  19. #[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
  20. #[ORM\ManyToOne(targetEntity: User::class)]
  21. private User $student;
  22. #[ORM\Column(name: 'confirmedCooperation', type: 'boolean')]
  23. private bool $confirmedCooperation = false;
  24. public function setConfirmedCooperation(bool $confirmedCooperation): PeerStudent
  25. {
  26. $this->confirmedCooperation = $confirmedCooperation;
  27. return $this;
  28. }
  29. public function getConfirmedCooperation(): bool
  30. {
  31. return $this->confirmedCooperation;
  32. }
  33. public function getId(): int
  34. {
  35. return $this->id;
  36. }
  37. public function setPeerUnit(PeerUnit $peerUnit): PeerStudent
  38. {
  39. $this->peerUnit = $peerUnit;
  40. return $this;
  41. }
  42. public function getPeerUnit(): PeerUnit
  43. {
  44. return $this->peerUnit;
  45. }
  46. public function setStudent(User $student): PeerStudent
  47. {
  48. $this->student = $student;
  49. return $this;
  50. }
  51. public function getStudent(): User
  52. {
  53. return $this->student;
  54. }
  55. public function setIsTeamLeader(bool $isTeamLeader): PeerStudent
  56. {
  57. $this->isTeamLeader = $isTeamLeader;
  58. return $this;
  59. }
  60. public function getIsTeamLeader(): bool
  61. {
  62. return $this->isTeamLeader;
  63. }
  64. public function jsonSerialize(): mixed
  65. {
  66. return [
  67. "id" => $this->id,
  68. "isTeamLeader" => $this->isTeamLeader,
  69. "studentName" => $this->getStudent()->getFullName(),
  70. ];
  71. }
  72. }