Since Laravel uses brilliant Carbon class for handle dates it's as easy as this:
// consider created_at is the field you want to query on the model called News
$date = new Carbon\Carbon; // DateTime string will be 2014-04-03 13:57:34
$date->subWeek(); // or $date->subDays(7), 2014-03-27 13:58:25
News::where('created_at', '>', $date->toDateTimeString() )->get();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community