src/Entity/Lecture.php line 49

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use App\Controller\Api\Controller\Course\Lesson\FinishedController;
  7. use App\Controller\Api\Controller\Course\Lesson\FinishedLectures;
  8. use App\Controller\Api\Controller\Course\StudentLectureController;
  9. use App\Repository\LectureRepository;
  10. use Doctrine\ORM\Mapping as ORM;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. #[ORM\Entity(repositoryClassLectureRepository::class)]
  13. #[ApiResource(
  14.     normalizationContext: ['groups' => ['read:lecture:collection']],
  15.     operations: [
  16.         new GetCollection(
  17.             uriTemplate'/student/{id}/lectures',
  18.             controllerStudentLectureController::class,
  19.             readfalse,
  20.             openapiContext: [
  21.                 'security' => [['bearerAuth' => []]]
  22.             ]
  23.         ),
  24.         new GetCollection(
  25.             uriTemplate'/student/{id}/finished-lectures',
  26.             controllerFinishedLectures::class,
  27.             readfalse,
  28.             openapiContext: [
  29.                 'security' => [['bearerAuth' => []]]
  30.             ]
  31.         ),
  32.         new Get(),
  33.         new Get(
  34.             uriTemplate'/lecture/{id}/finished',
  35.             controllerFinishedController::class,
  36.             readfalse,
  37.             normalizationContext: [
  38.                 'groups' => ['read:lesson:item']
  39.             ],
  40.             openapiContext: [
  41.                 'security' => [['bearerAuth' => []]]
  42.             ]
  43.         )
  44.     ]
  45. )]
  46. class Lecture
  47. {
  48.     #[ORM\Id]
  49.     #[ORM\GeneratedValue]
  50.     #[ORM\Column]
  51.     #[Groups(['read:lecture:collection'])]
  52.     private ?int $id null;
  53.     #[ORM\ManyToOne(inversedBy'lectures')]
  54.     #[ORM\JoinColumn(nullablefalse)]
  55.     private ?Eleve $eleve null;
  56.     #[ORM\ManyToOne(inversedBy'lectures')]
  57.     #[ORM\JoinColumn(nullabletrue)]
  58.     #[Groups(['read:lecture:collection'])]
  59.     private ?Lesson $lesson null;
  60.     #[ORM\Column]
  61.     #[Groups(['read:lecture:collection'])]
  62.     private ?\DateTimeImmutable $startAt null;
  63.     #[ORM\Column(nullabletrue)]
  64.     #[Groups(['read:lecture:collection'])]
  65.     private ?\DateTimeImmutable $endAt null;
  66.     #[ORM\Column]
  67.     #[Groups(['read:lecture:collection'])]
  68.     private ?bool $isFinished null;
  69.     #[ORM\Column(length255nullabletrue)]
  70.     #[Groups(['read:lecture:collection'])]
  71.     private ?string $reference null;
  72.     #[ORM\ManyToOne(inversedBy'lectures')]
  73.     #[Groups(['read:lecture:collection'])]
  74.     private ?Chapitre $chapitre null;
  75.     #[ORM\ManyToOne(inversedBy'lectures')]
  76.     #[Groups(['read:lecture:collection'])]
  77.     private ?Cours $cours null;
  78.     #[ORM\Column(nullabletrue)]
  79.     #[Groups(['read:lecture:collection'])]
  80.     private ?float $note null;
  81.     public function __construct()
  82.     {
  83.         $this->startAt = new \DateTimeImmutable();
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getEleve(): ?Eleve
  90.     {
  91.         return $this->eleve;
  92.     }
  93.     public function setEleve(?Eleve $eleve): self
  94.     {
  95.         $this->eleve $eleve;
  96.         return $this;
  97.     }
  98.     public function getLesson(): ?Lesson
  99.     {
  100.         return $this->lesson;
  101.     }
  102.     public function setLesson(?Lesson $lesson): self
  103.     {
  104.         $this->lesson $lesson;
  105.         return $this;
  106.     }
  107.     public function getStartAt(): ?\DateTimeImmutable
  108.     {
  109.         return $this->startAt;
  110.     }
  111.     public function setStartAt(\DateTimeImmutable $startAt): self
  112.     {
  113.         $this->startAt $startAt;
  114.         return $this;
  115.     }
  116.     public function getEndAt(): ?\DateTimeImmutable
  117.     {
  118.         return $this->endAt;
  119.     }
  120.     public function setEndAt(?\DateTimeImmutable $endAt): self
  121.     {
  122.         $this->endAt $endAt;
  123.         return $this;
  124.     }
  125.     public function isIsFinished(): ?bool
  126.     {
  127.         return $this->isFinished;
  128.     }
  129.     public function setIsFinished(bool $isFinished): self
  130.     {
  131.         $this->isFinished $isFinished;
  132.         return $this;
  133.     }
  134.     public function getReference(): ?string
  135.     {
  136.         return $this->reference;
  137.     }
  138.     public function setReference(?string $reference): self
  139.     {
  140.         $this->reference $reference;
  141.         return $this;
  142.     }
  143.     public function getChapitre(): ?Chapitre
  144.     {
  145.         return $this->chapitre;
  146.     }
  147.     public function setChapitre(?Chapitre $chapitre): self
  148.     {
  149.         $this->chapitre $chapitre;
  150.         return $this;
  151.     }
  152.     public function getCours(): ?Cours
  153.     {
  154.         return $this->cours;
  155.     }
  156.     public function setCours(?Cours $cours): self
  157.     {
  158.         $this->cours $cours;
  159.         return $this;
  160.     }
  161.     public function getNote(): ?float
  162.     {
  163.         return $this->note;
  164.     }
  165.     public function setNote(?float $note): self
  166.     {
  167.         $this->note $note;
  168.         return $this;
  169.     }
  170. }