Jean-louis Gouwy
Jean-louis Gouwy

Reputation: 182

Get my clients with only today's appointments

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

Upvotes: -1

Views: 135

Answers (2)

Jean-louis Gouwy
Jean-louis Gouwy

Reputation: 182

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

Upvotes: 0

Bogdan
Bogdan

Reputation: 713

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.

Upvotes: 1

Related Questions