<?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 RxConnexionBundle\Entity\AuditTrailEntity;
use JMS\Serializer\Annotation\Groups;

/**
 * @ORM\Entity(repositoryClass="RxConnexionBundle\Repository\InsuranceTypeRepository")
 * @ORM\Table(name="insurance_type", indexes={@ORM\Index(name="IDX_SEARCH_000", columns={"description"})})
 */

class InsuranceTypeEntity extends BaseEntity
{

    /**
     * @ORM\Column(type="string", nullable=true)
     * @Groups("forAudit")
     */
    protected $code;

    /**
     * @ORM\Column(type="string")
     * @Groups("forAudit")
     */
    protected $description;

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

    /**
     * @ORM\OneToMany(targetEntity="InsuranceEntity", mappedBy="insuranceType")
     */
    protected $insurances;

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

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


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

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



    /**
     * Set code
     *
     * @param string $code
     *
     * @return InsuranceTypeEntity
     */
    public function setCode($code)
    {
        $this->code = $code;

        return $this;
    }

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

    /**
     * Set description
     *
     * @param string $description
     *
     * @return InsuranceTypeEntity
     */
    public function setDescription($description)
    {
        $this->description = $description;

        return $this;
    }

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

    /**
     * Add insurance
     *
     * @param \RxConnexionBundle\Entity\InsuranceEntity $insurance
     *
     * @return InsuranceTypeEntity
     */
    public function addInsurance(\RxConnexionBundle\Entity\InsuranceEntity $insurance)
    {
        $this->insurances[] = $insurance;

        return $this;
    }

    /**
     * Remove insurance
     *
     * @param \RxConnexionBundle\Entity\InsuranceEntity $insurance
     */
    public function removeInsurance(\RxConnexionBundle\Entity\InsuranceEntity $insurance)
    {
        $this->insurances->removeElement($insurance);
    }

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

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

        return $this;
    }

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