<?php

namespace App\Entity;

use App\Repository\CarteFractalRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

#[ORM\Entity(repositoryClass: CarteFractalRepository::class)]
#[Vich\Uploadable]
class CarteFractal
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(length: 255)]
    private ?string $type = null;

    #[ORM\Column(length: 255)]
    private ?string $description = null;

    #[ORM\Column]
    private ?int $prix = null;

    #[ORM\Column(type: Types::DATE_MUTABLE)]
    private ?\DateTimeInterface $date = null;

    #[ORM\ManyToOne(inversedBy: 'cartesfractal')]
    private ?ClasseurFractal $classeurFractal = null;

        // NOTE: This is not a mapped field of entity metadata, just a simple property.
        #[Vich\UploadableField(mapping: 'cartes', fileNameProperty: 'imageName', size: 'imageSize')]
        private ?File $imageFile = null;
    
        #[ORM\Column(nullable: true)]
        private ?string $imageName = null;
    
        #[ORM\Column(nullable: true)]
        private ?int $imageSize = null;
    
        #[ORM\Column(nullable: true)]
        private ?\DateTimeImmutable $updatedAt = null;
    
        /**
         * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
         * of 'UploadedFile' is injected into this setter to trigger the update. If this
         * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
         * must be able to accept an instance of 'File' as the bundle will inject one here
         * during Doctrine hydration.
         *
         * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
         */
        public function setImageFile(?File $imageFile = null): void
        {
            $this->imageFile = $imageFile;
    
            if (null !== $imageFile) {
                // It is required that at least one field changes if you are using doctrine
                // otherwise the event listeners won't be called and the file is lost
                $this->updatedAt = new \DateTimeImmutable();
            }
        }
    
        public function getImageFile(): ?File
        {
            return $this->imageFile;
        }
    
        public function setImageName(?string $imageName): void
        {
            $this->imageName = $imageName;
        }
    
        public function getImageName(): ?string
        {
            return $this->imageName;
        }
    
        public function setImageSize(?int $imageSize): void
        {
            $this->imageSize = $imageSize;
        }
    
        public function getImageSize(): ?int
        {
            return $this->imageSize;
        }
    
    public function getId(): ?int
    {
        return $this->id;
    }

    public function getType(): ?string
    {
        return $this->type;
    }

    public function setType(string $type): static
    {
        $this->type = $type;

        return $this;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function setDescription(string $description): static
    {
        $this->description = $description;

        return $this;
    }

    public function getPrix(): ?int
    {
        return $this->prix;
    }

    public function setPrix(int $prix): static
    {
        $this->prix = $prix;

        return $this;
    }

    public function getDate(): ?\DateTimeInterface
    {
        return $this->date;
    }

    public function setDate(\DateTimeInterface $date): static
    {
        $this->date = $date;

        return $this;
    }

    public function getClasseurFractal(): ?ClasseurFractal
    {
        return $this->classeurFractal;
    }

    public function setClasseurFractal(?ClasseurFractal $classeurFractal): static
    {
        $this->classeurFractal = $classeurFractal;

        return $this;
    }

    public function __toString(): string
    {
        return $this->description;
    }

}
