src/Entity/Study.php line 30

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\GetCollection;
  5. use App\Entity\Traits\CreatedAtTrait;
  6. use App\Entity\Traits\UpdatedAtTrait;
  7. use App\Repository\StudyRepository;
  8. use DateTime;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  14. #[ORM\HasLifecycleCallbacks]
  15. #[Vich\Uploadable]
  16. #[ORM\Entity(repositoryClassStudyRepository::class)]
  17. #[ApiResource(
  18.     operations: [
  19.         new GetCollection(
  20.             uriTemplate'/user/study',
  21.             security"is_granted('ROLE_CLIENT')",
  22.         )
  23.     ],
  24.     normalizationContext: ['groups' => ['Study:read']],
  25.     order: ['createdAt'=>'DESC']
  26. )]
  27. class Study
  28. {
  29.     use CreatedAtTrait;
  30.     use UpdatedAtTrait;
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     #[Groups(['Study:read'])]
  35.     private ?int $id null;
  36.     #[Vich\UploadableField(mapping'study_video'fileNameProperty'video')]
  37.     #[Assert\File(mimeTypes: ['video/mp4'])]
  38.     private ?File $videoFile null;
  39.     #[ORM\Column(length255)]
  40.     #[Groups(['Study:read'])]
  41.     private ?string $video null;
  42.     #[Vich\UploadableField(mapping'study_file'fileNameProperty'linkPresentation')]
  43.     #[Assert\File(mimeTypes: ['application/pdf'])]
  44.     private ?File $linkPresentationFile null;
  45.     #[ORM\Column(length255)]
  46.     #[Groups(['Study:read'])]
  47.     private ?string $linkPresentation null;
  48.     public function getId(): ?int
  49.     {
  50.         return $this->id;
  51.     }
  52.     public function getVideo(): ?string
  53.     {
  54.         return $this->video;
  55.     }
  56.     public function setVideo(?string $video): self
  57.     {
  58.         $this->video $video;
  59.         return $this;
  60.     }
  61.     public function getVideoFile(): ?File
  62.     {
  63.         return $this->videoFile;
  64.     }
  65.     public function setVideoFile(?File $videoFile): void
  66.     {
  67.         $this->videoFile $videoFile;
  68.         if (null !== $videoFile) {
  69.             $this->updatedAt = new DateTime();
  70.         }
  71.     }
  72.     public function getLinkPresentation(): ?string
  73.     {
  74.         return $this->linkPresentation;
  75.     }
  76.     public function setLinkPresentation(?string $linkPresentation): self
  77.     {
  78.         $this->linkPresentation $linkPresentation;
  79.         return $this;
  80.     }
  81.     public function getLinkPresentationFile(): ?File
  82.     {
  83.         return $this->linkPresentationFile;
  84.     }
  85.     public function setLinkPresentationFile(?File $linkPresentation): void
  86.     {
  87.         $this->linkPresentationFile $linkPresentation;
  88.         if (null !== $linkPresentation) {
  89.             $this->updatedAt = new DateTime();
  90.         }
  91.     }
  92. }