Site Admin
Site Admin Founder of MeaningArticles
1236 Views

Laravel Get Last 7 Days Record

Hello Dev.

on this article, you may learn how to get last 7 days data in laravel the use of carbon. we are able to carbon for pick last 7 days records in laravel 5 eloquent query.

virtually, i love to proportion the entirety related to laravel. on every event i'm developing on my laravel utility, i be aware all of the small trouble that fetch and note solution so i'm able to write small web articles and someone can sole out his issue too.

currently, i was operating on my laravel 5.6 utility and i require to get remaining 30 days statistics from database table. i am working on laravel from long term so i realize i'm able to get last 30 days records from Carbon. So basically when you have additionally want to get last 7 days records then you can do it like as bellow technique.


Get Last 7 Days Data In Laravel

$date = \Carbon\Carbon::today()->subDays(30);
$users = User::where('created_at', '>=', $date)->get();

dd($users);

i'm hoping it assist you to, thanks for visit my article if you like my article then proportion together with your friend and social platform.