<?php

namespace RxConnexionBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
use RxConnexionBundle\Entity\Base\BaseEntity;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use JMS\Serializer\Annotation\Groups;


/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\ChatParticipantRepository")
 * @ORM\Table(name="chat_participant")
 */

class ChatParticipantEntity extends BaseEntity
{

    /**
     * @ORM\ManyToOne(targetEntity="ChatEntity", inversedBy="chatParticipants")
     * @ORM\JoinColumn(name="chat_id", referencedColumnName="id")
     */
    protected $chat;

    /**
     * @ORM\ManyToOne(targetEntity="AccountUserEntity", inversedBy="chatParticipants")
     * @ORM\JoinColumn(name="account_user_id", referencedColumnName="id")
     */
    protected $accountUser;

    /**
     * @ORM\Column(name="is_deleted", type="boolean")
     */
    protected $isDeleted;

    /**
     * @ORM\Column(name="seen_latest", type="boolean")
     */
    protected $seenLatest;

    /**
     * @ORM\OneToMany(targetEntity="ChatMessageEntity", mappedBy="chatParticipant")
     */
    protected $chatMessages;

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Use Defined Setters and Getters														  */
    /*--------------------------------------------------------------------------------------------------------*/

    /**
     * Set createdAt
     *
     * @ORM\PrePersist
     */
    public function setCreatedAtValue()
    {
        parent::setCreatedAtValue();
        $this->isDeleted = 0;
        $this->seenLatest = 0;
    }

    /*--------------------------------------------------------------------------------------------------------*/
    /*					Setters and Getters																	  */
    /*--------------------------------------------------------------------------------------------------------*/


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

    /**
     * Set isDeleted
     *
     * @param boolean $isDeleted
     *
     * @return ChatParticipantEntity
     */
    public function setIsDeleted($isDeleted)
    {
        $this->isDeleted = $isDeleted;

        return $this;
    }

    /**
     * Get isDeleted
     *
     * @return boolean
     */
    public function getIsDeleted()
    {
        return $this->isDeleted;
    }

    /**
     * Set chat
     *
     * @param \RxConnexionBundle\Entity\ChatEntity $chat
     *
     * @return ChatParticipantEntity
     */
    public function setChat(\RxConnexionBundle\Entity\ChatEntity $chat = null)
    {
        $this->chat = $chat;

        return $this;
    }

    /**
     * Get chat
     *
     * @return \RxConnexionBundle\Entity\ChatEntity
     */
    public function getChat()
    {
        return $this->chat;
    }

    /**
     * Set accountUser
     *
     * @param \RxConnexionBundle\Entity\AccountUserEntity $accountUser
     *
     * @return ChatParticipantEntity
     */
    public function setAccountUser(\RxConnexionBundle\Entity\AccountUserEntity $accountUser = null)
    {
        $this->accountUser = $accountUser;

        return $this;
    }

    /**
     * Get accountUser
     *
     * @return \RxConnexionBundle\Entity\AccountUserEntity
     */
    public function getAccountUser()
    {
        return $this->accountUser;
    }

    /**
     * Add chatMessage
     *
     * @param \RxConnexionBundle\Entity\ChatMessageEntity $chatMessage
     *
     * @return ChatParticipantEntity
     */
    public function addChatMessage(\RxConnexionBundle\Entity\ChatMessageEntity $chatMessage)
    {
        $this->chatMessages[] = $chatMessage;

        return $this;
    }

    /**
     * Remove chatMessage
     *
     * @param \RxConnexionBundle\Entity\ChatMessageEntity $chatMessage
     */
    public function removeChatMessage(\RxConnexionBundle\Entity\ChatMessageEntity $chatMessage)
    {
        $this->chatMessages->removeElement($chatMessage);
    }

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

    /**
     * Set seenLatest
     *
     * @param boolean $seenLatest
     *
     * @return ChatParticipantEntity
     */
    public function setSeenLatest($seenLatest)
    {
        $this->seenLatest = $seenLatest;

        return $this;
    }

    /**
     * Get seenLatest
     *
     * @return boolean
     */
    public function getSeenLatest()
    {
        return $this->seenLatest;
    }
}
