1
I need to list the schedules that have date greater or equal to the current date, I am doing the way below but does not work, it does not return any record.
Auth::user()->Agendamentos->where('data', '>=', date("Y-m-d h:i:s"))
I’m doing it in mine view
. If I take that where
works normally, but it lists everything, both with past date and with future date.
My field date stores the data in the format datetime
(2017-07-01 10:25:45).
Your field on the bench is one
DateTime
really, do you have a way to put the layout of your table? , because looking at it like this, it seems correct @Raylan– novic
Yes, that’s right. $table->datetime('date');
– Raylan Soares
Look, there’s only one answer, but basically if you do this or use it the same as your answer has to work the same way maybe you need to test it like this
Auth::user()->Agendas->Where('data', '>=', date("Y-m-d"))` and then tells me which result apparently gave, ie without time, minutes and seconds only the date?
– novic
also does not work. Strange that the query in phpmyadmin works correctly. SELECT * FROM
agendamentos
WHERE data >= '2017-06-01 11:29:57' ANDmedico_id
= 1– Raylan Soares
Use like this:
Auth::user()->Agendamentos()->where('data', '>=', date("Y-m-d h:i:s"))->get()
and tell me what happened? That is instead of the list, will use Where in the method!– novic
I changed the field type to date and compared using only date("Y-m-d"), but it doesn’t even work like that
– Raylan Soares
I think I’ll take this in the controller with a raw...
– Raylan Soares
Let’s go continue this discussion in chat.
– novic
how is your code in the controller?
– novic
There is nothing related to this in the controller, I’m picking up the relationship through the logged in user. Everything happens in the view with Auth::user()->Schedules
– Raylan Soares
is very confused! and it seems wrong to me also in a certain way, lack context so of the great doubt, well who knows you putting more details ...
– novic