How to Get Last 7 Days Record in Laravel?

By Hardik Savani | January 16, 2021 | Category : Laravel

This simple article demonstrates of laravel get last 7 days records. i explained simply about get last 7 days data in laravel. i explained simply step by step get last 7 days records in laravel. In this article, we will implement a laravel get last 7 days data from database.

we can easily get last 7 days records in laravel 6, laravel 7 and laravel 8 version.

i will show you simple code of controller method where we written code to getting last 7 days records using carbon laravel eloquent.

let's see controller code:

Controller File:


namespace App\Http\Controllers;

use Illuminate\Http\Request;

use Carbon\Carbon;

class UserController extends Controller



* Write code on Method


* @return response()


public function index()


$date = Carbon::now()->subDays(7);

$users = User::where('created_at', '>=', $date)->get();




I hope it can help you...

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.

We are Recommending you: