Search code examples
laravel-8laravel-query-builderphp-carbon

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!


Solution

  • It will display any record that is created in the past seven days. that means one week

    table::where('created_at', '>=', Carbon::now()->subDay(7))->get();