<?php

namespace App\Entity;

use App\Repository\ProduitPhotoRepository;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass=ProduitPhotoRepository::class)
 * @ORM\Table(schema="sav")
 */
class ProduitPhoto
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\ManyToOne(targetEntity=Produit::class, inversedBy="produitPhotos", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false, name="idproduit")
     */
    private $produit;

    /**
     * @ORM\Column(type="binary", nullable=true)
     */
    private $photo;

    /**
     * @ORM\Column(type="boolean", nullable=true)
     */
    private $photo_principale;

    /**
     * @ORM\Column(type="string", length=100, nullable=true)
     */
    private $nom;

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getProduit(): ?Produit
    {
        return $this->produit;
    }

    public function setProduit(?Produit $produit): self
    {
        $this->produit = $produit;

        return $this;
    }

    public function getPhoto()
    {
        return  stream_get_contents($this->photo);
    }

    public function setPhoto($photo): self
    {
        $this->photo = $photo;

        return $this;
    }

    public function getPhotoPrincipale(): ?bool
    {
        return $this->photo_principale;
    }

    public function setPhotoPrincipale(?bool $photo_principale): self
    {
        $this->photo_principale = $photo_principale;

        return $this;
    }

    public function getNom(): ?string
    {
        return $this->nom;
    }

    public function setNom(?string $nom): self
    {
        $this->nom = $nom;

        return $this;
    }
}
