Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

M@rty's avatar
Level 1

Laravel - Display query result for at least one week (query)

I am using Laravel 8

Writing a query, and want to display today's record(Dt.: 17/08/2022) for at least one week which means(at least for 7 days (Dt.: 24/08/2022)) using carbon.

After one week which means on 25th august records should be excluded from listing.

What should I do to archive this result? any help would be great!

Thank you!

0 likes
5 replies
Tray2's avatar

Something like

Record::where('created_at', '>=', Carbon::now()->subDay(7))->get();
M@rty's avatar
Level 1

@Tray2 pls see the Question again, I have edited (Dt.: 17/08/2022)

Tray2's avatar

@M@rty It will display any record that is created in the past seven days.

1 like
M@rty's avatar
Level 1

@tray2 Do you mean by tomorrow

I'll get the record from 11th Aug to 18th Aug

today I'll get records created from the 10th to 17th of Aug, right?

Please or to participate in this conversation.