Wednesday, March 8, 2017

Getting specific date ranges from database in Laravel

I need to get results from a DB divided by dates such as today, yesterday, this week, last week, etc.

I can easily do this with whereRaw and some SQL:

whereRaw('Date(created_at) = CURDATE()')->get();

I wonder if there is an easier, proper way to do this with Eloquent.



via prgrm

Advertisement