You could use query scopes:
public function scopeLast($query)
{
$today = new DateTime();
return $query->where('created_at', '>', $today->modify('-7 days'));
}
In your repository or controller you can then call it like this (or whatever you need):
User::last()->get();
This code is untested, but you get the idea.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community