Order by created_at not working with Eloquent models

Viewed 1929

I have a little issue when trying to order records by created_at column when using Eloquent Models. The ordering works by date but not by time. Example if I have 3 records with created_at values:

  • 2017-07-04 07:16:33

  • 2017-07-04 05:35:01

  • 2017-07-04 05:27:48

    I have the same output when using orderby('created_at', 'desc') or 'asc'. Ordering however works if i have for example

  • 2017-07-04 05:27:48

  • 2017-07-03 06:35:50

Ordering works also when I use raw queries. The issue is present only when I use Eloquent Model.

Has anyone any idea why is this happening? Thanks in advance

2 Answers
Related