src/Entity/DocteurTime.php line 34

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the kProjet project.
  4.  *
  5.  * (c) Kodiom <info@kodiom.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace App\Entity;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. use App\Entity\Docteur as Docteur;
  14. use ApiPlatform\Core\Annotation\ApiResource;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. /**
  18.  * DocteurTime
  19.  *
  20.  * @ORM\Table()
  21.  * @ORM\Entity(repositoryClass="App\Entity\DocteurTimeRepository")
  22.  * @ApiResource(
  23.  *     attributes={
  24.  *       "force_eager"=false,
  25.  *       "normalization_context"={"groups"={"read", "user", "media"}},
  26.  *       "denormalization_context"={"groups"={"read", "user", "media"}}
  27.  *     }
  28.  * )
  29.  */
  30. class DocteurTime
  31. {
  32.     /**
  33.      * @var int
  34.      *
  35.      * @ORM\Column(name="id", type="integer")
  36.      * @ORM\Id
  37.      * @ORM\GeneratedValue(strategy="AUTO")
  38.      *
  39.      * @Groups({"read"})
  40.      */
  41.     private $id;
  42.     /**
  43.      * @var bool
  44.      *
  45.      * @ORM\Column(name="etat", type="boolean")
  46.      * @Groups({"read"})
  47.      */
  48.     private $etat;
  49.     /**
  50.      * @var datetime
  51.      *
  52.      * @ORM\Column(name="dateInfo", type="datetime")
  53.      * @Groups({"read"})
  54.      */
  55.     private $dateInfo;
  56.     /**
  57.      * @var ArrayCollection
  58.      *
  59.      * @ORM\ManyToOne(targetEntity="App\Entity\Docteur", cascade={"persist"})
  60.      * @ORM\JoinColumn(name="docteur_id", referencedColumnName="id", onDelete="SET NULL")
  61.      * @Groups({"read"})
  62.      */
  63.     private $docteur;
  64.     /**
  65.      * Constructor of DocteurTime Entity
  66.      */
  67.     public function __construct()
  68.     {
  69.         $this->dateInfo = new \DateTime;
  70.     }
  71.     public function __toString()
  72.     {
  73.         if($this->getEtat()){
  74.             if($this->getDocteur()) return $this->getDocteur()->getUser()->getFirstname().' '.$this->getEtat();
  75.             else return 'Unknown';
  76.         }
  77.         else return 'Unknown';
  78.     }
  79.     /**
  80.      * Get id
  81.      *
  82.      * @return integer
  83.      */
  84.     public function getId()
  85.     {
  86.         return $this->id;
  87.     }
  88.     /**
  89.      * Get etat
  90.      *
  91.      * @return boolean
  92.      */
  93.     public function getEtat()
  94.     {
  95.         return $this->etat;
  96.     }
  97.     /**
  98.      * Set etat
  99.      *
  100.      * @param bool $etat
  101.      *
  102.      * @return DocteurTime
  103.      */
  104.     public function setEtat($etat)
  105.     {
  106.         $this->etat $etat;
  107.         return $this;
  108.     }
  109.     /**
  110.      * Get dateInfo
  111.      *
  112.      * @return datetime
  113.      */
  114.     public function getDateInfo()
  115.     {
  116.         return $this->dateInfo;
  117.     }
  118.     /**
  119.      * Set dateInfo
  120.      *
  121.      * @param datetime $dateInfo
  122.      *
  123.      * @return DocteurTime
  124.      */
  125.     public function setDateInfo($dateInfo)
  126.     {
  127.         $this->dateInfo $dateInfo;
  128.         return $this;
  129.     }
  130.     /**
  131.      * Get docteur
  132.      *
  133.      * @return ArrayCollection
  134.      */
  135.     public function getDocteur()
  136.     {
  137.         return $this->docteur;
  138.     }
  139.     /**
  140.      * Set docteur
  141.      *
  142.      * @param Docteur $docteur
  143.      *
  144.      * @return DocteurTime
  145.      */
  146.     public function setDocteur($docteur)
  147.     {
  148.         $this->docteur $docteur;
  149.         return $this;
  150.     }
  151. }