<?php
namespace App\Entity;
use App\Entity\Traits\Timestampable;
use App\Repository\HomeWorkRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation\Groups;
#[ORM\Table(name: "home_work")]
#[ORM\Index(columns: ["content"], name: "home_work",flags: ['fulltext'])]
#[ORM\HasLifecycleCallbacks]
#[ORM\Entity(repositoryClass: HomeWorkRepository::class)]
class HomeWork
{
use Timestampable;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['homework'])]
private ?int $id = null;
#[ORM\Column(type: Types::TEXT,nullable: true)]
#[Groups(['homework'])]
private ?string $content = null;
#[ORM\Column(nullable: true)]
private ?bool $inBook = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['homework'])]
private ?string $fileName = null;
#[ORM\ManyToOne(inversedBy: 'homeWorks', cascade: ["persist"])]
#[Groups(['homework'])]
private ?Subject $subject = null;
#[ORM\ManyToOne(inversedBy: 'homeWorks', cascade: ["persist"])]
#[Groups(['homework'])]
private ?TheClass $classe = null;
#[ORM\ManyToOne(inversedBy: 'homeWorks', cascade: ["persist"])]
#[ORM\JoinColumn(nullable: false)]
private ?SchoolYear $year = null;
#[ORM\Column(type: Types::DATE_MUTABLE)]
#[Groups(['homework'])]
private ?\DateTimeInterface $correctionDate = null;
#[ORM\ManyToOne(inversedBy: 'homeWorks', cascade: ["persist"])]
private ?User $author = null;
#[ORM\ManyToOne(inversedBy: 'homeworksEdited', cascade: ["persist"])]
private ?User $editor = null;
#[ORM\ManyToOne(inversedBy: 'homeWorks', cascade: ["persist"])]
private ?School $school = null;
#[ORM\OneToMany(mappedBy: 'homework', targetEntity: HomeworkBookmark::class)]
private Collection $homeworkBookmarks;
public function __construct()
{
$this->homeworkBookmarks = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(string $content): static
{
$this->content = $content;
return $this;
}
public function isInBook(): ?bool
{
return $this->inBook;
}
public function setInBook(?bool $inBook): static
{
$this->inBook = $inBook;
return $this;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileName(?string $fileName): static
{
$this->fileName = $fileName;
return $this;
}
public function getSubject(): ?Subject
{
return $this->subject;
}
public function setSubject(?Subject $subject): static
{
$this->subject = $subject;
return $this;
}
public function getClasse(): ?TheClass
{
return $this->classe;
}
public function setClasse(?TheClass $classe): static
{
$this->classe = $classe;
return $this;
}
public function getYear(): ?SchoolYear
{
return $this->year;
}
public function setYear(?SchoolYear $year): static
{
$this->year = $year;
return $this;
}
public function getCorrectionDate(): ?\DateTimeInterface
{
return $this->correctionDate;
}
public function setCorrectionDate(\DateTimeInterface $correctionDate): static
{
$this->correctionDate = $correctionDate;
return $this;
}
public function getAuthor(): ?User
{
return $this->author;
}
public function setAuthor(?User $author): static
{
$this->author = $author;
return $this;
}
public function getEditor(): ?User
{
return $this->editor;
}
public function setEditor(?User $editor): static
{
$this->editor = $editor;
return $this;
}
public function getSchool(): ?School
{
return $this->school;
}
public function setSchool(?School $school): static
{
$this->school = $school;
return $this;
}
/**
* @return Collection<int, HomeworkBookmark>
*/
public function getHomeworkBookmarks(): Collection
{
return $this->homeworkBookmarks;
}
public function addHomeworkBookmark(HomeworkBookmark $homeworkBookmark): static
{
if (!$this->homeworkBookmarks->contains($homeworkBookmark)) {
$this->homeworkBookmarks->add($homeworkBookmark);
$homeworkBookmark->setHomework($this);
}
return $this;
}
public function removeHomeworkBookmark(HomeworkBookmark $homeworkBookmark): static
{
if ($this->homeworkBookmarks->removeElement($homeworkBookmark)) {
// set the owning side to null (unless already changed)
if ($homeworkBookmark->getHomework() === $this) {
$homeworkBookmark->setHomework(null);
}
}
return $this;
}
}