<?php

namespace AppBundle\Entity\Booking;

use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Dunglas\ApiBundle\Annotation\Iri;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use AppBundle\Entity\AccessAndFunction\Access;

/**
 * Périodes de vacances d'un Access
 *
 * @Iri("http://schema.org/PersonHoliday")
 *
 */
#[ORM\Entity]
class PersonHoliday extends AbstractBooking
{
    /**
     * @var ArrayCollection<PersonHolidayRecur>
     */
    #[Assert\Valid]
    #[ORM\OneToMany(targetEntity: 'PersonHolidayRecur', mappedBy: 'event', cascade: ['persist'], orphanRemoval: true)]
    #[Groups(['personholiday_bookingrecur', 'accessholidays_list'])]
    protected $eventRecur;
    /**
     * @var Access
     */
    #[ORM\ManyToOne(targetEntity: '\AppBundle\Entity\AccessAndFunction\Access', inversedBy: 'holidays')]
    #[Groups(['personholiday', 'accessholidays_list'])]
    private $access;
    /**
     * @var bool
     */
    #[ORM\Column(type: 'boolean', options: ['default' => false])]
    #[Assert\Type(type: 'boolean')]
    #[Assert\NotNull]
    #[Groups(['personholiday'])]
    private $approval = false;
    /**
     * @var int
     */
    #[ORM\Column(type: 'integer', nullable: true, options: ['default' => 0])]
    #[Assert\Type(type: 'integer', message: 'invalid-integer')]
    #[Groups(['personholiday'])]
    private $unpaidLeave;
    public function __construct()
    {
        parent::__construct();
        $this->eventRecur = new ArrayCollection();
    }
    /**
     * Sets access.
     * 
     * @param Access $access
     * 
     * @return $this
     */
    public function setAccess(Access $access = null)
    {
        $this->access = $access;

        return $this;
    }
    /**
     * Gets access.
     * 
     * @return Access
     */
    public function getAccess()
    {
        return $this->access;
    }
    /**
     * Sets approval.
     * 
     * @param bool $approval
     * 
     * @return $this
     */
    public function setApproval($approval)
    {
        $this->approval = $approval;

        return $this;
    }
    /**
     * Gets approval.
     * 
     * @return bool
     */
    public function getApproval()
    {
        return $this->approval;
    }
    /**
     * Sets unpaidLeave.
     * 
     * @param int $unpaidLeave
     * 
     * @return $this
     */
    public function setUnpaidLeave($unpaidLeave)
    {
        $this->unpaidLeave = $unpaidLeave;

        return $this;
    }
    /**
     * Gets unpaidLeave.
     * 
     * @return int
     */
    public function getUnpaidLeave()
    {
        return $this->unpaidLeave;
    }
}
