src/Entity/MarketAppImage.php line 22

  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use ApiPlatform\Metadata\Get;
  5. use ApiPlatform\Metadata\GetCollection;
  6. use App\Entity\Traits\CreatedAtTrait;
  7. use App\Entity\Traits\UpdatedAtTrait;
  8. use App\Repository\MarketAppImageRepository;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Bridge\Doctrine\Types\UlidType;
  11. use Symfony\Component\HttpFoundation\File\File;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. use Symfony\Component\Uid\Ulid;
  14. use Symfony\Component\Validator\Constraints as Assert;
  15. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  16. #[ORM\HasLifecycleCallbacks]
  17. #[Vich\Uploadable]
  18. #[ORM\Entity(repositoryClassMarketAppImageRepository::class)]
  19. class MarketAppImage
  20. {
  21.     use CreatedAtTrait;
  22.     use UpdatedAtTrait;
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue]
  25.     #[ORM\Column]
  26.     #[Groups(['read''MarketCategory:read'])]
  27.     private ?int $id null;
  28.     #[Vich\UploadableField(mapping'screenshots_file'fileNameProperty'image')]
  29.     #[Assert\Image(mimeTypes: ['image/png''image/jpeg''image/jpg'])]
  30.     private ?File $imageFile null;
  31.     #[ORM\Column(length255nullabletrue)]
  32.     #[Groups(['read''MarketCategory:read'])]
  33.     private ?string $image null;
  34.     #[ORM\ManyToOne(inversedBy'images')]
  35.     private ?MarketApp $marketApp null;
  36.     public function getId(): ?int
  37.     {
  38.         return $this->id;
  39.     }
  40.     public function getImage(): ?string
  41.     {
  42.         return $this->image;
  43.     }
  44.     public function setImage(?string $image): self
  45.     {
  46.         $this->image $image;
  47.         return $this;
  48.     }
  49.     public function getImageFile(): ?File
  50.     {
  51.         return $this->imageFile;
  52.     }
  53.     public function setImageFile(?File $imageFile): void
  54.     {
  55.         $this->imageFile $imageFile;
  56.         if (null !== $imageFile) {
  57.             $this->updatedAt = new \DateTime();
  58.         }
  59.     }
  60.     public function getMarketApp(): ?MarketApp
  61.     {
  62.         return $this->marketApp;
  63.     }
  64.     public function setMarketApp(?MarketApp $marketApp): self
  65.     {
  66.         $this->marketApp $marketApp;
  67.         return $this;
  68.     }
  69. }