src/Entity/Appointment.php line 75

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiResource;
  4. use App\Controller\AppointmentController;
  5. use App\Controller\CountAppointmentController;
  6. use App\Repository\AppointmentRepository;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Serializer\Annotation\Groups;
  10. #[ORM\Entity(repositoryClassAppointmentRepository::class)]
  11. #[ApiResource(
  12.     collectionOperations:[
  13.         'get',
  14.         'post',
  15.         'countAppointmentsUser' => [
  16.             'method' => 'GET',
  17.             'path' => '/users/{id}/appointments/count',
  18.             'controller' =>  CountAppointmentController::class,
  19.             'openapi_context' => [
  20.                 'summary' => 'Count Appointments per User',
  21.                 'parameters' => [
  22.                     [
  23.                         'in' => 'query',
  24.                         'name' => 'id',
  25.                         'schema' => [
  26.                             'type' => 'integer'
  27.                         ]
  28.                     ]
  29.                 ],
  30.                 'response' => [
  31.                     '200' => [
  32.                         'description' => 'OK',
  33.                         'content' => [
  34.                             'application/json' => [
  35.                                 'schema' => [
  36.                                     'type' => 'integer'
  37.                                 ]
  38.                             ]
  39.                         ]
  40.                     ]
  41.                 ]
  42.             ]
  43.         ]
  44.     ],
  45.     itemOperations: [
  46.         'put',
  47.         'delete',
  48.         'get' => [
  49.         'normalization_context' => ['groups' => ['read:User:collection''read:User:item']],
  50.         ],
  51.         'appointementsByUser' => [
  52.             'method' => 'GET',
  53.             'path' => '/users/{userId}/appointments',
  54.             'controller' => AppointmentController::class,
  55.             'openapi_context' => [
  56.                 'summary' => 'Display Appointments per User',
  57.                 'parameters' => [
  58.                     [
  59.                         'in' => 'query',
  60.                         'name' => 'userId',
  61.                         'schema' => [
  62.                             'type' => 'integer'
  63.                         ]
  64.                     ]
  65.                 ]
  66.             ]
  67.         ],
  68.     ],
  69.     denormalizationContext: ['groups' => ['read:User:collection''write:User']],
  70.     normalizationContext: ['groups' => ['read:User:collection']]
  71. )]
  72. class Appointment
  73. {
  74.     #[ORM\Id]
  75.     #[ORM\GeneratedValue]
  76.     #[ORM\Column]
  77.     #[Groups(['read:User:collection'])]
  78.     private ?int $id null;
  79.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  80.     #[Groups(['read:User:collection''write:User'])]
  81.     private ?\DateTimeInterface $appointment_at null;
  82.     #[ORM\Column]
  83.     #[Groups(['read:User:collection'])]
  84.     private ?\DateTimeImmutable $created_at null;
  85.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  86.     #[Groups(['read:User:collection'])]
  87.     private ?\DateTimeInterface $updated_at null;
  88.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  89.     #[Groups(['read:User:item''write:User'])]
  90.     private ?string $infos_sup null;
  91.     #[ORM\ManyToOne(inversedBy'appointments')]
  92.     #[Groups(['read:User:item'])]
  93.     private ?User $patient null;
  94.     #[ORM\ManyToOne(inversedBy'appointments')]
  95.     #[Groups(['read:User:item'])]
  96.     private ?User $doctor null;
  97.     #[ORM\Column(length255)]
  98.     #[Groups(['read:User:item''write:User''read:User:collection'])]
  99.     private ?string $status 'Encours';
  100.     public function getId(): ?int
  101.     {
  102.         return $this->id;
  103.     }
  104.     public function getAppointmentAt(): ?\DateTimeInterface
  105.     {
  106.         return $this->appointment_at;
  107.     }
  108.     public function setAppointmentAt(\DateTimeInterface $appointment_at): static
  109.     {
  110.         $this->appointment_at $appointment_at;
  111.         return $this;
  112.     }
  113.     public function getCreatedAt(): ?\DateTimeImmutable
  114.     {
  115.         return $this->created_at;
  116.     }
  117.     public function setCreatedAt(\DateTimeImmutable $created_at): static
  118.     {
  119.         $this->created_at $created_at;
  120.         return $this;
  121.     }
  122.     public function getUpdatedAt(): ?\DateTimeInterface
  123.     {
  124.         return $this->updated_at;
  125.     }
  126.     public function setUpdatedAt(?\DateTimeInterface $updated_at): static
  127.     {
  128.         $this->updated_at $updated_at;
  129.         return $this;
  130.     }
  131.     public function getInfosSup(): ?string
  132.     {
  133.         return $this->infos_sup;
  134.     }
  135.     public function setInfosSup(?string $infos_sup): static
  136.     {
  137.         $this->infos_sup $infos_sup;
  138.         return $this;
  139.     }
  140.     public function getPatient(): ?object
  141.     {
  142.         return $this->patient;
  143.     }
  144.     public function setPatient(?object $patient): static
  145.     {
  146.         $this->patient $patient;
  147.         return $this;
  148.     }
  149.     public function getDoctor(): ?object
  150.     {
  151.         return $this->doctor;
  152.     }
  153.     public function setDoctor(?object $doctor): static
  154.     {
  155.         $this->doctor $doctor;
  156.         return $this;
  157.     }
  158.     public function getStatus(): ?string
  159.     {
  160.         return $this->status;
  161.     }
  162.     public function setStatus(string $status): static
  163.     {
  164.         $this->status $status;
  165.         return $this;
  166.     }
  167. }