Get my clients with only today's appointments

125 views Asked by At

i'm not used to develop with Symfony, I retrieved an old project which has to be improved.

Here is my problem : In back-end, I have clients with several appointments (HasMany), or none. In front-end, from my rest api call, I receive the clients with appointments. No problem. But I would like to receive only appointments of today ("start" attribute in appointment model).

How can I apply that directly in back-end ? I know there are a lot of way to use symfony with Doctrine and annotations ... but can't find the right answer.

Thanks

2

There are 2 answers

4
Bogdan On

Erm.. you select everything from your table with the today day nothing too fancy. :-) ex:

"SELECT * FROM appointments WHERE date >= CURDATE()"

Of course this would need to be translated to doctrine but you have the above example to start.

0
Jean-louis Gouwy On

here the request I don't success to apply in my repository with query builder:

SELECT * 
FROM ikc_client
LEFT JOIN (
  SELECT *
  FROM ikc_appointment
  WHERE ikc_appointment.start > '2018-08-07 00:00:00'
  AND ikc_appointment.end < '2018-08-07 23:59:59'
) appointment ON appointment.client_id = ikc_client.id