Reputation: 2072
How can I find when user last time added record and take that record?
Something like this:
Comment::where('user_id',Auth::id())->where(HERE I NEED TO GET BIGEST create_at)->first();
Any solution for this?
Upvotes: 0
Views: 1405
Reputation: 507
Use the orderby statement:
Comment::where('user_id', Auth::id())->orderBy('created_at', 'desc')->first();
See: http://laravel.com/docs/5.1/queries#ordering-grouping-limit-and-offset
For more info.
Upvotes: 3