<?php

namespace AppBundle\Entity;

use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;

/**
 * Phonebook
 * @ORM\Table(name="phonebook")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\PhonebookRepository")
 */
class Phonebook
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

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

    /**
     * @var string
     * @Assert\NotBlank(message="Le numero de telephone est obligatoire")
     * @ORM\Column(name="gsm", type="string", length=11, nullable=false)
     */
    private $gsm;


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

    /**
    * @var \UserBundle\Entity\User
    *
    * @ORM\ManyToOne(targetEntity="\UserBundle\Entity\User",  inversedBy="phonebook")
    * @ORM\JoinColumn(name="owner", referencedColumnName="id", nullable=false)
    */
    private $owner;

    /**
     * One Product has Many Features.
     * @ORM\OneToMany(targetEntity="\AppBundle\Entity\MobileTerminated", mappedBy="phonebook")
     */
    private $mailbox;

    /**
     * @var \DateTime
     *
     * @ORM\Column(name="createdAt", type="datetime")
     */
    private $createdAt;

    /**
     * @var int
     *
     * @ORM\Column(name="del", type="integer", nullable=false)
    **/
    private $del;



    /**
     * Get id
     *
     * @return int
     */
    public function getId()
    {
        return $this->id;
    }


    /**
     * Set name
     *
     * @param string $name
     *
     * @return Phonebook
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

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

    /**
     * Set gsm
     *
     * @param string $gsm
     *
     * @return Phonebook
     */
    public function setGsm($gsm)
    {
        $this->gsm = $gsm;

        return $this;
    }

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

    /**
     * Set email
     *
     * @param string $email
     *
     * @return Phonebook
     */
    public function setEmail($email)
    {
        $this->email = $email;

        return $this;
    }

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

    /**
     * Set createdAt
     *
     * @param \DateTime $createdAt
     *
     * @return Phonebook
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;

        return $this;
    }

    /**
     * Get createdAt
     *
     * @return \DateTime
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * Set del
     *
     * @param integer $del
     *
     * @return Phonebook
     */
    public function setDel($del)
    {
        $this->del = $del;

        return $this;
    }

    /**
     * Get del
     *
     * @return integer
     */
    public function getDel()
    {
        return $this->del;
    }

    /**
     * Set owner
     *
     * @param \UserBundle\Entity\User $owner
     *
     * @return Phonebook
     */
    public function setOwner(\UserBundle\Entity\User $owner = null)
    {
        $this->owner = $owner;

        return $this;
    }

    /**
     * Get owner
     *
     * @return \UserBundle\Entity\User
     */
    public function getOwner()
    {
        return $this->owner;
    }

    public function __toString(){
        return $this->gsm;
    }
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->mailbox = new \Doctrine\Common\Collections\ArrayCollection();
    }

    /**
     * Add mailbox
     *
     * @param \AppBundle\Entity\MobileTerminated $mailbox
     *
     * @return Phonebook
     */
    public function addMailbox(\AppBundle\Entity\MobileTerminated $mailbox)
    {
        $this->mailbox[] = $mailbox;

        return $this;
    }

    /**
     * Remove mailbox
     *
     * @param \AppBundle\Entity\MobileTerminated $mailbox
     */
    public function removeMailbox(\AppBundle\Entity\MobileTerminated $mailbox)
    {
        $this->mailbox->removeElement($mailbox);
    }

    /**
     * Get mailbox
     *
     * @return \Doctrine\Common\Collections\Collection
     */
    public function getMailbox()
    {
        return $this->mailbox;
    }
}
