<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use App\Repository\ClientRepository;
use App\Entity\User as User;
/**
* @ORM\Table()
* @ORM\Entity(repositoryClass=ClientRepository::class)
* @ApiResource(
* attributes={
* "filters"={"client.order", "client.filter", "client.boolean"},
* "force_eager"=false,
* "normalization_context"={"groups"={"read", "user", "media", "read-user"}},
* "denormalization_context"={"groups"={"read", "user", "media"}}
* }
* )
*/
class Client
{
/**
* @var integer $id
*
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @Groups({"read"})
*/
private $id;
/**
* @var text
*
* @ORM\Column(name="adresse", type="string", length=255, nullable=true)
* @Groups({"read","user"})
*/
private $adresse;
/**
* @var text
*
* @ORM\Column(name="poids", type="string", length=50, nullable=true)
* @Groups({"read","user"})
*/
private $poids;
/**
* @var text
*
* @ORM\Column(name="taille", type="string", length=50, nullable=true)
* @Groups({"read","user"})
*/
private $taille;
/**
* @var text
*
* @ORM\Column(name="groupeSanguin", type="string", length=50, nullable=true)
* @Groups({"read","user"})
*/
private $groupeSanguin;
/**
* @var text
*
* @ORM\Column(name="allergie", type="string", length=255, nullable=true)
* @Groups({"read","user"})
*/
private $allergie;
/**
* @var User
* @ORM\OneToOne(
* targetEntity="App\Entity\User",
* cascade={"persist", "remove"},
* mappedBy="client"
* )
* @Groups({"user"})
*/
private $user;
/**
* @var datetime
*
* @ORM\Column(name="dateInfo", type="date")
*
* @Assert\NotBlank()
* @Groups({"read"})
*/
private $dateInfo;
/**
* @var bool
*
* @ORM\Column(name="invite", type="boolean")
* @Groups({"read","user"})
*/
private $invite;
/**
* @var bool
*
* @ORM\Column(name="actif", type="boolean")
* @Groups({"read","user"})
*/
private $actif;
/**
* @ORM\OneToMany(targetEntity=Ordonnance::class, mappedBy="client")
*/
private $ordonnances;
/**
* @ORM\OneToMany(targetEntity=ArretTravail::class, mappedBy="client")
*/
private $arrets;
/**
* @ORM\OneToMany(targetEntity=FeuilleSoin::class, mappedBy="client")
*/
private $feuilles;
/**
* Constructor of Client Entity
*/
public function __construct()
{
$this->invite = false;
$this->actif = true;
$this->dateInfo = new \DateTime;
$this->ordonnances = new ArrayCollection();
$this->arrets = new ArrayCollection();
$this->feuilles = new ArrayCollection();
}
public function __toString()
{
return ($this->getUser()) ? $this->getUser()->getUsername() : 'Unknown';
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Get adresse
*
* @return string
*/
public function getAdresse()
{
return $this->adresse;
}
/**
* Set adresse
*
* @param string $adresse
*
* @return Client
*/
public function setAdresse($adresse)
{
$this->adresse = $adresse;
return $this;
}
/**
* Get poids
*
* @return string
*/
public function getPoids()
{
return $this->poids;
}
/**
* Set poids
*
* @param string $poids
*
* @return Client
*/
public function setPoids($poids)
{
$this->poids = $poids;
return $this;
}
/**
* Get taille
*
* @return string
*/
public function getTaille()
{
return $this->taille;
}
/**
* Set taille
*
* @param string $taille
*
* @return Client
*/
public function setTaille($taille)
{
$this->taille = $taille;
return $this;
}
/**
* Get groupeSanguin
*
* @return string
*/
public function getGroupeSanguin()
{
return $this->groupeSanguin;
}
/**
* Set groupeSanguin
*
* @param string $groupeSanguin
*
* @return Client
*/
public function setGroupeSanguin($groupeSanguin)
{
$this->groupeSanguin = $groupeSanguin;
return $this;
}
/**
* Get allergie
*
* @return string
*/
public function getAllergie()
{
return $this->allergie;
}
/**
* Set allergie
*
* @param string $allergie
*
* @return Client
*/
public function setAllergie($allergie)
{
$this->allergie = $allergie;
return $this;
}
/**
* Get user
*
* @return User
*/
public function getUser()
{
return $this->user;
}
/**
* Set user
*
* @param User $user
*
* @return Client
*/
public function setUser(User $user)
{
$this->user = $user;
return $this;
}
/**
* Get dateInfo
*
* @return datetime
*/
public function getDateInfo()
{
return $this->dateInfo;
}
/**
* Set dateInfo
*
* @param datetime $dateInfo
*
* @return Intervention
*/
public function setDateInfo($dateInfo)
{
$this->dateInfo = $dateInfo;
return $this;
}
/**
* Get getDateInfoInfoString
*
* @return \DateTime
* @Groups({"read"})
*/
public function getDateInfoInfoString()
{
return $this->dateInfo->format('Y-m-d');
}
/**
* Get invite
*
* @return boolean
*/
public function getInvite()
{
return $this->invite;
}
/**
* Set invite
*
* @param bool $invite
*
* @return Client
*/
public function setInvite($invite)
{
$this->invite = $invite;
return $this;
}
/**
* Get actif
*
* @return boolean
*/
public function getActif()
{
return $this->actif;
}
/**
* Set actif
*
* @param bool $actif
*
* @return Client
*/
public function setActif($actif)
{
$this->actif = $actif;
return $this;
}
/**
* @return mixed
*/
public function getOrdonnances()
{
return $this->ordonnances;
}
/**
* @param mixed $ordonnances
*/
public function setOrdonnances($ordonnances)
{
$this->ordonnances = $ordonnances;
}
}