<?php
namespace App\Entity\Core\Peer;
use App\Entity\User\User;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Table('peer_student')]
#[ORM\Entity]
class PeerStudent implements JsonSerializable
{
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private int $id;
#[ORM\Column(name: 'is_team_leader', type: 'boolean', options: ['default' => false])]
private bool $isTeamLeader;
#[ORM\JoinColumn(name: 'PeerUnit', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: PeerUnit::class, inversedBy: 'peerStudents')]
private PeerUnit $peerUnit;
#[ORM\JoinColumn(name: 'user_id', referencedColumnName: 'id')]
#[ORM\ManyToOne(targetEntity: User::class)]
private User $student;
#[ORM\Column(name: 'confirmedCooperation', type: 'boolean')]
private bool $confirmedCooperation = false;
public function setConfirmedCooperation(bool $confirmedCooperation): PeerStudent
{
$this->confirmedCooperation = $confirmedCooperation;
return $this;
}
public function getConfirmedCooperation(): bool
{
return $this->confirmedCooperation;
}
public function getId(): int
{
return $this->id;
}
public function setPeerUnit(PeerUnit $peerUnit): PeerStudent
{
$this->peerUnit = $peerUnit;
return $this;
}
public function getPeerUnit(): PeerUnit
{
return $this->peerUnit;
}
public function setStudent(User $student): PeerStudent
{
$this->student = $student;
return $this;
}
public function getStudent(): User
{
return $this->student;
}
public function setIsTeamLeader(bool $isTeamLeader): PeerStudent
{
$this->isTeamLeader = $isTeamLeader;
return $this;
}
public function getIsTeamLeader(): bool
{
return $this->isTeamLeader;
}
public function jsonSerialize(): mixed
{
return [
"id" => $this->id,
"isTeamLeader" => $this->isTeamLeader,
"studentName" => $this->getStudent()->getFullName(),
];
}
}