<?php

namespace App\Entity;

use App\Behavior\Timestampable;
use Doctrine\ORM\Mapping as ORM;
use App\Repository\MenuRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Vich\UploaderBundle\Mapping\Annotation as Vich;

/**
 * @ORM\Entity(repositoryClass=MenuRepository::class)
 * @ORM\HasLifecycleCallbacks()
 * @Vich\Uploadable()
 */
class Menu
{
    use Timestampable;

    public function __construct()
    {
        $this->extra = new ArrayCollection();
    }

    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=50)
     */
    private $name;

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

    /**
     * @ORM\Column(type="boolean")
     */
    private $isActive;

    /**
     * @ORM\Column(type="boolean")
     */
    private $haveSize;

    /**
     * @ORM\Column(type="boolean")
     */
    private $haveExtra;

    /**
     * @ORM\Column(type="decimal", precision=10, scale=2, nullable=true)
     */
    private $pvp;

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

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

    /**
     * @Vich\UploadableField(mapping="menu_image", fileNameProperty="image")
     */
    private $imageFile;

    /**
     * @ORM\OneToOne(targetEntity=Category::class, mappedBy="menu", orphanRemoval=true)
     */
    private $category;

    /**
     * @ORM\OneToMany(targetEntity=Size::class, mappedBy="menu", orphanRemoval=true)
     */
    private $size;

    /**
     * @ORM\OneToMany(targetEntity=ExtraType::class, mappedBy="menu", orphanRemoval=true)
     */
    private $extraType;

    /**
     * @ORM\ManyToOne(targetEntity=Restaurant::class, inversedBy="menu", cascade={"remove","persist"})
     * @ORM\JoinColumn(onDelete="CASCADE")
     */
    private $restaurant;

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

    public function getName(): ?string
    {
        return $this->name;
    }

    public function setName(string $name): self
    {
        $this->name = $name;

        return $this;
    }

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

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

        return $this;
    }

    public function isIsActive(): ?bool
    {
        return $this->isActive;
    }

    public function setIsActive(bool $isActive): self
    {
        $this->isActive = $isActive;

        return $this;
    }

    public function getPvp(): ?string
    {
        return $this->pvp;
    }

    public function setPvp(string $pvp): self
    {
        $this->pvp = $pvp;

        return $this;
    }

    /**
     * Get the value of haveSize
     */
    public function getHaveSize()
    {
        return $this->haveSize;
    }

    /**
     * Set the value of haveSize
     *
     * @return  self
     */
    public function setHaveSize($haveSize)
    {
        $this->haveSize = $haveSize;

        return $this;
    }

    /**
     * Get the value of haveExtra
     */
    public function getHaveExtra()
    {
        return $this->haveExtra;
    }

    /**
     * Set the value of haveExtra
     *
     * @return  self
     */
    public function setHaveExtra($haveExtra)
    {
        $this->haveExtra = $haveExtra;

        return $this;
    }

    /**
     * Get the value of size
     */
    public function getSize()
    {
        return $this->size;
    }

    /**
     * Set the value of size
     *
     * @return  self
     */
    public function setSize($size)
    {
        $this->size = $size;

        return $this;
    }

    /**
     * Get the value of restaurant
     */
    public function getRestaurant()
    {
        return $this->restaurant;
    }

    /**
     * Set the value of restaurant
     *
     * @return  self
     */
    public function setRestaurant($restaurant)
    {
        $this->restaurant = $restaurant;

        return $this;
    }

    /**
     * Get the value of category
     */
    public function getCategory()
    {
        return $this->category;
    }

    /**
     * Set the value of category
     *
     * @return  self
     */
    public function setCategory($category)
    {
        $this->category = $category;

        return $this;
    }

    /**
     * Get the value of image
     */
    public function getImage()
    {
        return $this->image;
    }

    /**
     * Set the value of image
     *
     * @return  self
     */
    public function setImage($image)
    {
        $this->image = $image;

        return $this;
    }

    /**
     * Get the value of imageFile
     */
    public function getImageFile()
    {
        return $this->imageFile;
    }

    /**
     * Set the value of imageFile
     *
     * @return  self
     */
    public function setImageFile($imageFile)
    {
        $this->imageFile = $imageFile;

        return $this;
    }

    /**
     * Get the value of position
     */
    public function getPosition()
    {
        return $this->position;
    }

    /**
     * Set the value of position
     *
     * @return  self
     */
    public function setPosition($position)
    {
        $this->position = $position;

        return $this;
    }

    public function getRestaurantName()
    {
        return $this->restaurant->getName();
    }


    /**
     * Get the value of extraType
     */
    public function getExtraType()
    {
        return $this->extraType;
    }

    /**
     * Set the value of extraType
     *
     * @return  self
     */
    public function setExtraType($extraType)
    {
        $this->extraType = $extraType;

        return $this;
    }

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