src/Entity/Notification.php line 39

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Validator\Constraints as Assert;
  5. use App\Entity\Intervention;
  6. use App\Entity\Docteur;
  7. use ApiPlatform\Core\Annotation\ApiResource;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  11. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
  12. use ApiPlatform\Core\Annotation\ApiFilter;
  13. /**
  14.  * Notification
  15.  *
  16.  * @ORM\Table()
  17.  * @ORM\Entity(repositoryClass="App\Repository\NotificationRepository")
  18.  * @ApiResource(
  19.  *     attributes={
  20.  *       "filters"={"notification.order", "notification.search", "notification.boolean", "notification.date"},
  21.  *       "force_eager"=false,
  22.  *       "normalization_context"={"groups"={"read", "user", "media"}},
  23.  *       "denormalization_context"={"groups"={"read", "user", "media"}}
  24.  *     },
  25.  *     collectionOperations={
  26.  *        "get"={"method"="GET"}
  27.  *     },
  28.  *     itemOperations={
  29.  *        "get"={"method"="GET"},
  30.  *        "delete"={"method"="DELETE"}
  31.  *     }
  32.  * )
  33.  * @ApiFilter(SearchFilter::class, properties={"docteur.id": "exact", "intervention.etat": "exact", "actif": "exact"})
  34.  * @ApiFilter(DateFilter::class, properties={"dateInfo"})
  35.  */
  36. class Notification
  37. {
  38.     /**
  39.      * @var int
  40.      *
  41.      * @ORM\Column(name="id", type="integer")
  42.      * @ORM\Id
  43.      * @ORM\GeneratedValue(strategy="AUTO")
  44.      * @Groups({"read"})
  45.      */
  46.     private $id;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="type", type="string", length=50)
  51.      *
  52.      * @Assert\NotBlank()
  53.      * @Groups({"read"})
  54.      */
  55.     private $type;
  56.     /**
  57.      * @var ArrayCollection
  58.      *
  59.      * @ORM\ManyToOne(targetEntity=Intervention::class)
  60.      * @Groups({"read"})
  61.      */
  62.     private $intervention;
  63.     /**
  64.      * @var Docteur
  65.      *
  66.      * @ORM\ManyToOne(targetEntity=Docteur::class)
  67.      * @ORM\JoinColumn(name="docteur_id", referencedColumnName="id", onDelete="CASCADE")
  68.      * @Groups({"read"})
  69.      */
  70.     private $docteur;
  71.     /**
  72.      * @var date
  73.      *
  74.      * @ORM\Column(name="dateInfo", type="datetime")
  75.      */
  76.     private $dateInfo;
  77.     /**
  78.      * @var bool
  79.      *
  80.      * @ORM\Column(name="actif", type="boolean")
  81.      * @Groups({"read"})
  82.      */
  83.     private $actif;
  84.     /**
  85.      * Constructor of Notification Entity
  86.      */
  87.     public function __construct()
  88.     {
  89.         $this->type 'urgence';
  90.         $this->dateInfo = new \DateTime;
  91.         $this->actif true;
  92.     }
  93.     public function __toString()
  94.     {
  95.         return ($this->getType()) ? $this->getType() : '';
  96.     }
  97.     /**
  98.      * Get id
  99.      *
  100.      * @return integer
  101.      */
  102.     public function getId()
  103.     {
  104.         return $this->id;
  105.     }
  106.     /**
  107.      * Get type
  108.      *
  109.      * @return string
  110.      */
  111.     public function getType()
  112.     {
  113.         return $this->type;
  114.     }
  115.     /**
  116.      * Set type
  117.      *
  118.      * @param string $type
  119.      *
  120.      * @return Notification
  121.      */
  122.     public function setType($type)
  123.     {
  124.         $this->type $type;
  125.         return $this;
  126.     }
  127.     /**
  128.      * Get intervention
  129.      *
  130.      * @return ArrayCollection
  131.      */
  132.     public function getIntervention()
  133.     {
  134.         return $this->intervention;
  135.     }
  136.     /**
  137.      * Set intervention
  138.      *
  139.      * @param Intervention $intervention
  140.      *
  141.      * @return Notification
  142.      */
  143.     public function setIntervention(Intervention $intervention)
  144.     {
  145.         $this->intervention $intervention;
  146.         return $this;
  147.     }
  148.     /**
  149.      * Get docteur
  150.      *
  151.      * @return ArrayCollection
  152.      */
  153.     public function getDocteur()
  154.     {
  155.         return $this->docteur;
  156.     }
  157.     /**
  158.      * Set docteur
  159.      *
  160.      * @param Docteur $docteur
  161.      *
  162.      * @return Notification
  163.      */
  164.     public function setDocteur(Docteur $docteur)
  165.     {
  166.         $this->docteur $docteur;
  167.         return $this;
  168.     }
  169.     /**
  170.      * Get dateInfo
  171.      *
  172.      * @return date
  173.      */
  174.     public function getDateInfo()
  175.     {
  176.         return $this->dateInfo;
  177.     }
  178.     /**
  179.      * Set dateInfo
  180.      *
  181.      * @param date $dateInfo
  182.      *
  183.      * @return Notification
  184.      */
  185.     public function setDateInfo($dateInfo)
  186.     {
  187.         $this->dateInfo $dateInfo;
  188.         return $this;
  189.     }
  190.     /**
  191.      * Get getDateInfoString
  192.      *
  193.      * @return \DateTime
  194.      * @Groups({"read"})
  195.      */
  196.     public function getDateInfoString()
  197.     {
  198.         return $this->dateInfo->format('Y-m-d');
  199.     }
  200.     /**
  201.      * Get getDateTimeInfoString
  202.      *
  203.      * @return \DateTime
  204.      * @Groups({"read"})
  205.      */
  206.     public function getDateTimeInfoString()
  207.     {
  208.         return $this->dateInfo->format('c');
  209.     }
  210.     /**
  211.      * Get actif
  212.      *
  213.      * @return boolean
  214.      */
  215.     public function getActif()
  216.     {
  217.         return $this->actif;
  218.     }
  219.     /**
  220.      * Set actif
  221.      *
  222.      * @param bool $actif
  223.      *
  224.      * @return Intervention
  225.      */
  226.     public function setActif($actif)
  227.     {
  228.         $this->actif $actif;
  229.         return $this;
  230.     }
  231. }