<?php

namespace AppBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Oh\GoogleMapFormTypeBundle\Validator\Constraints as OhAssert;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;


/**
 * Interview
 *
 * @ORM\Table(name="interview")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\InterviewRepository")
 */
class Interview
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=255)
     */
    private $title;

    /**
     * @var string
     *
     * @ORM\Column(name="subtitle", type="string", length=255)
     */
    private $subtitle;
	
    /**
     * @var string
     *
     * @ORM\Column(name="quotation", type="string", length=255, nullable=true)
     */
    private $quotation;
	
	/**
     * @Gedmo\Slug(fields={"title","author"})
     * @ORM\Column(name="slug", type="string", length=255, unique=true)
     */
    protected $slug;

    /**
     * @var string
     *
     * @ORM\Column(name="author", type="string", length=255)
     */
    private $author;

     /**
	 * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Image",cascade={"persist"})
	 * @ORM\JoinColumn(nullable=true)
	 */
    private $photo;

    /**
     * @var string
     *
     * @ORM\Column(name="address", type="string", length=255)
     */
    private $address;
	
	/**
     * @var string
     *
     * @ORM\Column(name="latitude", type="decimal",scale=7, nullable=true)
     */
    private $latitude;

    /**
     * @var string
     *
     * @ORM\Column(name="longitude", type="decimal", scale=7, nullable=true)
     */
    private $longitude;
	
	private $latlng;

    /**
     * @var string
     *
     * @ORM\Column(name="resume", type="text")
     */
    private $resume;

    /**
     * @var string
     *
     * @ORM\Column(name="content", type="text", nullable=true)
     */
    private $content;
	
	 /**
	 * @ORM\OneToMany(targetEntity="AppBundle\Entity\QuestionAnswer", mappedBy="interview", cascade={"persist"}, orphanRemoval=true)
	 * @ORM\JoinColumn(nullable=false)
	 */
	private $questionanswers;

    /**
     * @var bool
     *
     * @ORM\Column(name="published", type="boolean")
     */
    private $published;


    /**
     * Get id
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title
     *
     * @param string $title
     *
     * @return Interview
     */
    public function setTitle($title)
    {
        $this->title = $title;

        return $this;
    }

    /**
     * Get title
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set subtitle
     *
     * @param string $subtitle
     *
     * @return Interview
     */
    public function setSubtitle($subtitle)
    {
        $this->subtitle = $subtitle;

        return $this;
    }

    /**
     * Get subtitle
     *
     * @return string
     */
    public function getSubtitle()
    {
        return $this->subtitle;
    }

    /**
     * Set author
     *
     * @param string $author
     *
     * @return Interview
     */
    public function setAuthor($author)
    {
        $this->author = $author;

        return $this;
    }

    /**
     * Get author
     *
     * @return string
     */
    public function getAuthor()
    {
        return $this->author;
    }

    /**
     * Set address
     *
     * @param string $address
     *
     * @return Interview
     */
    public function setAddress($address)
    {
        $this->address = $address;

        return $this;
    }

    /**
     * Get address
     *
     * @return string
     */
    public function getAddress()
    {
        return $this->address;
    }

    /**
     * Set resume
     *
     * @param string $resume
     *
     * @return Interview
     */
    public function setResume($resume)
    {
        $this->resume = $resume;

        return $this;
    }

    /**
     * Get resume
     *
     * @return string
     */
    public function getResume()
    {
        return $this->resume;
    }

    /**
     * Set content
     *
     * @param string $content
     *
     * @return Interview
     */
    public function setContent($content)
    {
        $this->content = $content;

        return $this;
    }

    /**
     * Get content
     *
     * @return string
     */
    public function getContent()
    {
        return $this->content;
    }

    /**
     * Set published
     *
     * @param boolean $published
     *
     * @return Interview
     */
    public function setPublished($published)
    {
        $this->published = $published;

        return $this;
    }

    /**
     * Get published
     *
     * @return bool
     */
    public function getPublished()
    {
        return $this->published;
    }
    	
    public function setLatLng($latlng)
    {
        $this->setLatitude($latlng['lat']);
        $this->setLongitude($latlng['lng']);
        return $this;
    }

    /**
     * @Assert\NotBlank()
     * @OhAssert\LatLng()
     */
    public function getLatLng()
    {
        return array('lat'=>$this->getLatitude(),'lng'=>$this->getLongitude());
    }

    /**
     * Set slug
     *
     * @param string $slug
     *
     * @return Interview
     */
    public function setSlug($slug)
    {
        $this->slug = $slug;

        return $this;
    }

    /**
     * Get slug
     *
     * @return string
     */
    public function getSlug()
    {
        return $this->slug;
    }

    /**
     * Set latitude
     *
     * @param string $latitude
     *
     * @return Interview
     */
    public function setLatitude($latitude)
    {
        $this->latitude = $latitude;

        return $this;
    }

    /**
     * Get latitude
     *
     * @return string
     */
    public function getLatitude()
    {
        return $this->latitude;
    }

    /**
     * Set longitude
     *
     * @param string $longitude
     *
     * @return Interview
     */
    public function setLongitude($longitude)
    {
        $this->longitude = $longitude;

        return $this;
    }

    /**
     * Get longitude
     *
     * @return string
     */
    public function getLongitude()
    {
        return $this->longitude;
    }

    /**
     * Set photo
     *
     * @param \AppBundle\Entity\Image $photo
     *
     * @return Interview
     */
    public function setPhoto(\AppBundle\Entity\Image $photo = null)
    {
        $this->photo = $photo;

        return $this;
    }

    /**
     * Get photo
     *
     * @return \AppBundle\Entity\Image
     */
    public function getPhoto()
    {
        return $this->photo;
    }   
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->questionanswers = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Add questionanswer
     *
     * @param \AppBundle\Entity\QuestionAnswer $questionanswer
     *
     * @return Interview
     */
    public function addQuestionanswer(\AppBundle\Entity\QuestionAnswer $questionanswer)
    {
		$questionanswer->setInterview($this);
        $this->questionanswers[] = $questionanswer;

        return $this;
    }

    /**
     * Remove questionanswer
     *
     * @param \AppBundle\Entity\QuestionAnswer $questionanswer
     */
    public function removeQuestionanswer(\AppBundle\Entity\QuestionAnswer $questionanswer)
    {
        $this->questionanswers->removeElement($questionanswer);
    }
	
	public function setQuestionanswers($questionanswers)
	{
		if (count($questionanswers) > 0) {
			foreach ($questionanswers as $i) {
				$this->addQuestionanswer($i);
			}
		}
	
		return $this;
	}

    /**
     * Get questionanswers
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getQuestionanswers()
    {
        return $this->questionanswers;
    }

    /**
     * Set quotation
     *
     * @param string $quotation
     *
     * @return Interview
     */
    public function setQuotation($quotation)
    {
        $this->quotation = $quotation;

        return $this;
    }

    /**
     * Get quotation
     *
     * @return string
     */
    public function getQuotation()
    {
        return $this->quotation;
    }
}
