<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use App\Entity\Intervention;
use App\Entity\Docteur;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\Common\Collections\ArrayCollection;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
use ApiPlatform\Core\Annotation\ApiFilter;
/**
* Notification
*
* @ORM\Table()
* @ORM\Entity(repositoryClass="App\Repository\NotificationRepository")
* @ApiResource(
* attributes={
* "filters"={"notification.order", "notification.search", "notification.boolean", "notification.date"},
* "force_eager"=false,
* "normalization_context"={"groups"={"read", "user", "media"}},
* "denormalization_context"={"groups"={"read", "user", "media"}}
* },
* collectionOperations={
* "get"={"method"="GET"}
* },
* itemOperations={
* "get"={"method"="GET"},
* "delete"={"method"="DELETE"}
* }
* )
* @ApiFilter(SearchFilter::class, properties={"docteur.id": "exact", "intervention.etat": "exact", "actif": "exact"})
* @ApiFilter(DateFilter::class, properties={"dateInfo"})
*/
class Notification
{
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @Groups({"read"})
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=50)
*
* @Assert\NotBlank()
* @Groups({"read"})
*/
private $type;
/**
* @var ArrayCollection
*
* @ORM\ManyToOne(targetEntity=Intervention::class)
* @Groups({"read"})
*/
private $intervention;
/**
* @var Docteur
*
* @ORM\ManyToOne(targetEntity=Docteur::class)
* @ORM\JoinColumn(name="docteur_id", referencedColumnName="id", onDelete="CASCADE")
* @Groups({"read"})
*/
private $docteur;
/**
* @var date
*
* @ORM\Column(name="dateInfo", type="datetime")
*/
private $dateInfo;
/**
* @var bool
*
* @ORM\Column(name="actif", type="boolean")
* @Groups({"read"})
*/
private $actif;
/**
* Constructor of Notification Entity
*/
public function __construct()
{
$this->type = 'urgence';
$this->dateInfo = new \DateTime;
$this->actif = true;
}
public function __toString()
{
return ($this->getType()) ? $this->getType() : '';
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set type
*
* @param string $type
*
* @return Notification
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get intervention
*
* @return ArrayCollection
*/
public function getIntervention()
{
return $this->intervention;
}
/**
* Set intervention
*
* @param Intervention $intervention
*
* @return Notification
*/
public function setIntervention(Intervention $intervention)
{
$this->intervention = $intervention;
return $this;
}
/**
* Get docteur
*
* @return ArrayCollection
*/
public function getDocteur()
{
return $this->docteur;
}
/**
* Set docteur
*
* @param Docteur $docteur
*
* @return Notification
*/
public function setDocteur(Docteur $docteur)
{
$this->docteur = $docteur;
return $this;
}
/**
* Get dateInfo
*
* @return date
*/
public function getDateInfo()
{
return $this->dateInfo;
}
/**
* Set dateInfo
*
* @param date $dateInfo
*
* @return Notification
*/
public function setDateInfo($dateInfo)
{
$this->dateInfo = $dateInfo;
return $this;
}
/**
* Get getDateInfoString
*
* @return \DateTime
* @Groups({"read"})
*/
public function getDateInfoString()
{
return $this->dateInfo->format('Y-m-d');
}
/**
* Get getDateTimeInfoString
*
* @return \DateTime
* @Groups({"read"})
*/
public function getDateTimeInfoString()
{
return $this->dateInfo->format('c');
}
/**
* Get actif
*
* @return boolean
*/
public function getActif()
{
return $this->actif;
}
/**
* Set actif
*
* @param bool $actif
*
* @return Intervention
*/
public function setActif($actif)
{
$this->actif = $actif;
return $this;
}
}