Level 104
$ads = Ad::whereDate('created_at', '>=', today()->subDays(7))->count();
What is the where('clone_ad') constraint supposed to be doing?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
so i want to get column count for the past 7days please how can i do this
$date = \Carbon\Carbon::today()->subDays(7);
$ads = Ads::where('clone_ad')->where('created_at','>=',$date)->get();
@kikter is clone_ad an INT type you want to total?
$ads = Ad::query()
->whereDate('created_at', '>=', today()->subDays(7))
->sum('clone_ad');
Or do you want a count of the rows where clone_ad has a particular value?
$ads = Ad::query()
->where('clone_ad', /* some value */)
->whereDate('created_at', '>=', today()->subDays(7))
->count();
Please or to participate in this conversation.