Support the ongoing development of Laravel.io →
Configuration Database Eloquent
Last updated 2 years ago.
0

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.

http://laravel.com/docs/eloquent#query-scopes

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

discolando discolando Joined 19 Aug 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.