<?php
namespace App\Entity\Core\Textbook;
use App\Entity\Core\Classroom\Classroom;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
#[ORM\Table('textbook_session')]
#[ORM\Entity(repositoryClass: TextbookSessionRepository::class)]
class TextbookSession implements JsonSerializable
{
/**
* @var int
*/
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;
/**
* @var Classroom
*/
#[ORM\JoinColumn(name: 'classroom', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[ORM\ManyToOne(targetEntity: Classroom::class, inversedBy: 'sessions')]
private $classroom;
/**
* @var ArrayCollection|TextbookSubTopic[]
*/
#[ORM\JoinTable(name: 'textbook_session_subtopic')]
#[ORM\JoinColumn(name: 'textbook_session', referencedColumnName: 'id')]
#[ORM\InverseJoinColumn(name: 'subtopic', referencedColumnName: 'id')]
#[ORM\ManyToMany(targetEntity: TextbookSubTopic::class, inversedBy: 'textbookSessions')]
private $textbookSubtopics;
/**
* @var DateTime
*/
#[ORM\Column(name: 'start_time', type: 'datetime', nullable: true)]
private $startTime;
#[ORM\Column(name: 'deadline', type: 'datetime')]
private $deadline;
#[ORM\Column(type: 'string', nullable: true)]
private $name;
#[ORM\Column(type: 'text', nullable: true)]
private $notice;
/**
* @var TextbookSessionUnit[]
*/
#[ORM\OneToMany(targetEntity: TextbookSessionUnit::class, mappedBy: 'session', cascade: ['persist'])]
private $units;
/**
* @var integer
*/
#[ORM\Column(type: 'integer', nullable: false, options: ['default' => 1])]
private $isEnabled = 1;
/**
* @return Classroom
*/
public function getClassroom()
{
return $this->classroom;
}
/**
* @param Classroom $classroom
*/
public function setClassroom($classroom)
{
$this->classroom = $classroom;
}
/**
* @return DateTime
*/
public function getStartTime()
{
return $this->startTime;
}
/**
* @param DateTime $startTime
*/
public function setStartTime($startTime)
{
$this->startTime = $startTime;
}
/**
* @return DateTime
*/
public function getDeadline()
{
return $this->deadline;
}
/**
* @param DateTime $deadline
*/
public function setDeadline($deadline)
{
$this->deadline = $deadline;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return int
*/
public function getId()
{
return $this->id;
}
/**
*
*/
public function resetId()
{
$this->id = null;
}
/**
* @return TextbookSubTopic[]|ArrayCollection
*/
public function getTextbookSubtopics()
{
return $this->textbookSubtopics;
}
/**
* @param TextbookSubTopic[]|ArrayCollection $textbookSubtopics
*/
public function setTextbookSubtopics($textbookSubtopics)
{
$this->textbookSubtopics = $textbookSubtopics;
}
/**
* @return TextbookSessionUnit[]
*/
public function getUnits()
{
return $this->units;
}
/**
* @param TextbookSessionUnit[] $units
*/
public function setUnits($units)
{
$this->units = $units;
}
public function getNotice(): ?string
{
return $this->notice;
}
public function setNotice(?String $notice)
{
$this->notice = $notice;
}
public function getisEnabled(): int
{
return $this->isEnabled;
}
public function setIsEnabled(int $isEnabled): void
{
$this->isEnabled = $isEnabled;
}
public function jsonSerialize(): mixed
{
return [
"id" => $this->getId(),
"name" => $this->getName(),
"startTime" => $this->getStartTime(),
"deadline" => $this->getDeadline(),
];
}
}