src/Entity/Order/OrderItemPhoto.php line 32

  1. <?php
  2. /*
  3.  * This file is part of the Pellipop project.
  4.  *
  5.  * (c) Mobizel
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace App\Entity\Order;
  12. use App\Entity\Media\File;
  13. use App\OrderItemPhotoStates;
  14. use App\Repository\Order\OrderItemPhotoRepository;
  15. use App\Validator\Constraints\OrderItemPhotosMaxCount;
  16. use Doctrine\ORM\Mapping as ORM;
  17. use Monofony\Contracts\Core\Model\Media\FileInterface;
  18. use Symfony\Component\Serializer\Annotation\Groups;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  21. /**
  22.  * @Vich\Uploadable
  23.  */
  24. #[ORM\Entity(repositoryClassOrderItemPhotoRepository::class)]
  25. #[ORM\Table(name'app_order_item_photo')]
  26. #[OrderItemPhotosMaxCount()]
  27. class OrderItemPhoto extends File implements FileInterface
  28. {
  29.     /**
  30.      * @Vich\UploadableField(mapping="order_item_photo", fileNameProperty="path")
  31.      */
  32.     #[Assert\Image(maxSize'100M')]
  33.     protected ?\SplFileInfo $file null;
  34.     #[ORM\ManyToOne(inversedBy'photos')]
  35.     #[ORM\JoinColumn(nullablefalse)]
  36.     private ?OrderItem $orderItem null;
  37.     #[ORM\Column(length20)]
  38.     #[Groups(['image:read'])]
  39.     private ?string $state null;
  40.     #[ORM\Column(length1000nullabletrue)]
  41.     #[Groups(['image:read'])]
  42.     private ?string $tag null;
  43.     public function __construct()
  44.     {
  45.         $this->state OrderItemPhotoStates::STATE_NEW;
  46.         parent::__construct();
  47.     }
  48.     public function getOrderItem(): ?OrderItem
  49.     {
  50.         return $this->orderItem;
  51.     }
  52.     public function setOrderItem(?OrderItem $orderItem): self
  53.     {
  54.         $this->orderItem $orderItem;
  55.         return $this;
  56.     }
  57.     public function getState(): ?string
  58.     {
  59.         return $this->state;
  60.     }
  61.     public function setState(string $state): self
  62.     {
  63.         $this->state $state;
  64.         return $this;
  65.     }
  66.     public function getTag(): ?string
  67.     {
  68.         return $this->tag;
  69.     }
  70.     public function setTag(?string $tag): void
  71.     {
  72.         $this->tag $tag;
  73.     }
  74. }