src/Entity/Exam.php line 52

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
  4. use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
  5. use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
  6. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  7. use ApiPlatform\Metadata\ApiFilter;
  8. use ApiPlatform\Metadata\ApiResource;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Metadata\Get;
  11. use App\Repository\ExamRepository;
  12. use Doctrine\DBAL\Types\Types;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Symfony\Component\HttpFoundation\File\File;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. #[ORM\Entity(repositoryClassExamRepository::class)]
  17. #[ApiResource(
  18.     operations: [
  19.         new Get(
  20.             normalizationContext: [
  21.                 'groups' => ['read:exam:collection''read:exam:item']
  22.             ],
  23.         ),
  24.         new GetCollection(
  25.             normalizationContext: [
  26.                 'groups' => ['read:exam:collection']
  27.             ],
  28.         ),
  29.     ],
  30.     normalizationContext: [
  31.         'groups' => ['read:exam:collection']
  32.     ],
  33. ),
  34. ApiFilter(SearchFilter::class, properties: [
  35.     'title' => 'partial',
  36.     'language' => 'exact',
  37.     'category' => 'exact',
  38.     'classe' => 'exact',
  39.     'classe.specialite' => 'exact',
  40.     'classe.specialite.filiere' => 'exact',
  41.     'classe.skillLevel' => 'exact',
  42. ]),
  43. ApiFilter(BooleanFilter::class, properties: ['isValidated''isIsPublished']),
  44. ApiFilter(DateFilter::class, properties: ['publishedAt']),
  45. ApiFilter(OrderFilter::class, properties: ['id''publishedAt'], arguments: ['orderParameterName' => 'order']),
  46. ]
  47. class Exam
  48. {
  49.     #[ORM\Id]
  50.     #[ORM\GeneratedValue]
  51.     #[ORM\Column]
  52.     #[Groups(['read:exam:collection'])]
  53.     private ?int $id null;
  54.     #[ORM\Column(length255)]
  55.     #[Groups(['read:exam:item'])]
  56.     private ?string $sujet null;
  57.     #[ORM\Column(length255nullabletrue)]
  58.     #[Groups(['read:exam:item'])]
  59.     private ?string $correction null;
  60.     #[ORM\Column(length255)]
  61.     #[Groups(['read:exam:collection'])]
  62.     private ?string $title null;
  63.     #[ORM\Column(typeTypes::TEXT)]
  64.     #[Groups(['read:exam:collection'])]
  65.     private ?string $description null;
  66.     #[ORM\Column]
  67.     #[Groups(['read:exam:collection'])]
  68.     private ?\DateTimeImmutable $publishedAt null;
  69.     #[ORM\Column]
  70.     #[Groups(['read:exam:collection'])]
  71.     private ?bool $isPublished null;
  72.     #[ORM\ManyToOne(inversedBy'exams')]
  73.     #[ORM\JoinColumn(nullablefalse)]
  74.     #[Groups(['read:exam:collection'])]
  75.     private ?User $user null;
  76.     #[ORM\Column(length255)]
  77.     #[Groups(['read:exam:collection'])]
  78.     private ?string $reference null;
  79.     /**
  80.      * @var File
  81.      */
  82.     private $sujetFile;
  83.     /**
  84.      * @var File
  85.      */
  86.     private $correctionFile;
  87.     /**
  88.      * @var File
  89.      */
  90.     public File $image;
  91.     #[ORM\Column(nullabletrue)]
  92.     private ?bool $isValidated null;
  93.     #[ORM\Column(length50)]
  94.     private ?string $duration null;
  95.     #[ORM\ManyToOne(inversedBy'exams')]
  96.     private ?Classe $classe null;
  97.     #[ORM\ManyToOne(inversedBy'exams')]
  98.     private ?Categorie $category null;
  99.     #[ORM\Column(length255nullabletrue)]
  100.     private ?string $imageFile null;
  101.     #[ORM\Column(length50)]
  102.     private ?string $language null;
  103.     public function __construct()
  104.     {
  105.         $this->publishedAt = new \DateTimeImmutable();
  106.         $this->isPublished false;
  107.     }
  108.     public function getId(): ?int
  109.     {
  110.         return $this->id;
  111.     }
  112.     public function getSujet(): ?string
  113.     {
  114.         return $this->sujet;
  115.     }
  116.     public function setSujet(string $sujet): self
  117.     {
  118.         $this->sujet $sujet;
  119.         return $this;
  120.     }
  121.     public function getCorrection(): ?string
  122.     {
  123.         return $this->correction;
  124.     }
  125.     public function setCorrection(?string $correction): self
  126.     {
  127.         $this->correction $correction;
  128.         return $this;
  129.     }
  130.     public function getTitle(): ?string
  131.     {
  132.         return $this->title;
  133.     }
  134.     public function setTitle(string $title): self
  135.     {
  136.         $this->title $title;
  137.         return $this;
  138.     }
  139.     public function getDescription(): ?string
  140.     {
  141.         return $this->description;
  142.     }
  143.     public function setDescription(string $description): self
  144.     {
  145.         $this->description $description;
  146.         return $this;
  147.     }
  148.     public function getPublishedAt(): ?\DateTimeImmutable
  149.     {
  150.         return $this->publishedAt;
  151.     }
  152.     public function setPublishedAt(\DateTimeImmutable $publishedAt): self
  153.     {
  154.         $this->publishedAt $publishedAt;
  155.         return $this;
  156.     }
  157.     public function isIsPublished(): ?bool
  158.     {
  159.         return $this->isPublished;
  160.     }
  161.     public function setIsPublished(bool $isPublished): self
  162.     {
  163.         $this->isPublished $isPublished;
  164.         return $this;
  165.     }
  166.     public function getUser(): ?User
  167.     {
  168.         return $this->user;
  169.     }
  170.     public function setUser(?User $user): self
  171.     {
  172.         $this->user $user;
  173.         return $this;
  174.     }
  175.     public function getReference(): ?string
  176.     {
  177.         return $this->reference;
  178.     }
  179.     public function setReference(string $reference): self
  180.     {
  181.         $this->reference $reference;
  182.         return $this;
  183.     }
  184.     public function setSujetFile(File $sujetFile null)
  185.     {
  186.         $this->sujetFile $sujetFile;
  187.         return $this;
  188.     }
  189.     public function getSujetFile()
  190.     {
  191.         return $this->sujetFile;
  192.     }
  193.     public function setCorrectionFile(File $correctionFile null)
  194.     {
  195.         $this->correctionFile $correctionFile;
  196.         return $this;
  197.     }
  198.     public function getCorrectionFile()
  199.     {
  200.         return $this->correctionFile;
  201.     }
  202.     public function isIsValidated(): ?bool
  203.     {
  204.         return $this->isValidated;
  205.     }
  206.     public function setIsValidated(?bool $isValidated): self
  207.     {
  208.         $this->isValidated $isValidated;
  209.         return $this;
  210.     }
  211.     public function getDuration(): ?string
  212.     {
  213.         return $this->duration;
  214.     }
  215.     public function setDuration(string $duration): self
  216.     {
  217.         $this->duration $duration;
  218.         return $this;
  219.     }
  220.     public function getClasse(): ?Classe
  221.     {
  222.         return $this->classe;
  223.     }
  224.     public function setClasse(?Classe $classe): self
  225.     {
  226.         $this->classe $classe;
  227.         return $this;
  228.     }
  229.     public function getCategory(): ?Categorie
  230.     {
  231.         return $this->category;
  232.     }
  233.     public function setCategory(?Categorie $category): self
  234.     {
  235.         $this->category $category;
  236.         return $this;
  237.     }
  238.     public function getImageFile(): ?string
  239.     {
  240.         return $this->imageFile;
  241.     }
  242.     public function setImageFile(?string $imageFile): self
  243.     {
  244.         $this->imageFile $imageFile;
  245.         return $this;
  246.     }
  247.     public function getLanguage(): ?string
  248.     {
  249.         return $this->language;
  250.     }
  251.     public function setLanguage(string $language): self
  252.     {
  253.         $this->language $language;
  254.         return $this;
  255.     }
  256. }