Get records with date greater than the current one - Laravel 5.1

0

I need to list schedules that have date greater than or equal to the current date, I'm doing it as below but it does not work, it does not return any record.

Auth::user()->Agendamentos->where('data', '>=', date("Y-m-d h:i:s"))

I'm doing this on my view . If I take this where it works normally, however it lists everything, both with past and future dates.

My date field stores the data in the format datetime (2017-07-01 10:25:45).

    
asked by anonymous 01.06.2017 / 16:19

1 answer

1

First ensure that your dates are handled correctly in the global format that Carbon uses: link . ..

class SeuModelo {

    protected $dates = [
        'data',
    ];
    ...

The where filter you can use Carbon:

Auth::user()->Agendamentos->where('data', '>=', \Carbon::now())
    
01.06.2017 / 16:28