<?php
/*
* This file is part of the kProjet project.
*
* (c) Kodiom <info@kodiom.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\Docteur as Docteur;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\Common\Collections\ArrayCollection;
/**
* DocteurTime
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Entity\DocteurTimeRepository")
* @ApiResource(
* attributes={
* "force_eager"=false,
* "normalization_context"={"groups"={"read", "user", "media"}},
* "denormalization_context"={"groups"={"read", "user", "media"}}
* }
* )
*/
class DocteurTime
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Groups({"read"})
*/
private $id;
/**
* @var bool
*
* @ORM\Column(name="etat", type="boolean")
* @Groups({"read"})
*/
private $etat;
/**
* @var datetime
*
* @ORM\Column(name="dateInfo", type="datetime")
* @Groups({"read"})
*/
private $dateInfo;
/**
* @var ArrayCollection
*
* @ORM\ManyToOne(targetEntity="App\Entity\Docteur", cascade={"persist"})
* @ORM\JoinColumn(name="docteur_id", referencedColumnName="id", onDelete="SET NULL")
* @Groups({"read"})
*/
private $docteur;
/**
* Constructor of DocteurTime Entity
*/
public function __construct()
{
$this->dateInfo = new \DateTime;
}
public function __toString()
{
if($this->getEtat()){
if($this->getDocteur()) return $this->getDocteur()->getUser()->getFirstname().' '.$this->getEtat();
else return 'Unknown';
}
else return 'Unknown';
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get etat
*
* @return boolean
*/
public function getEtat()
{
return $this->etat;
}
/**
* Set etat
*
* @param bool $etat
*
* @return DocteurTime
*/
public function setEtat($etat)
{
$this->etat = $etat;
return $this;
}
/**
* Get dateInfo
*
* @return datetime
*/
public function getDateInfo()
{
return $this->dateInfo;
}
/**
* Set dateInfo
*
* @param datetime $dateInfo
*
* @return DocteurTime
*/
public function setDateInfo($dateInfo)
{
$this->dateInfo = $dateInfo;
return $this;
}
/**
* Get docteur
*
* @return ArrayCollection
*/
public function getDocteur()
{
return $this->docteur;
}
/**
* Set docteur
*
* @param Docteur $docteur
*
* @return DocteurTime
*/
public function setDocteur($docteur)
{
$this->docteur = $docteur;
return $this;
}
}